summaryrefslogtreecommitdiff
path: root/usr/src/lib/libc
diff options
context:
space:
mode:
Diffstat (limited to 'usr/src/lib/libc')
-rw-r--r--usr/src/lib/libc/port/sys/epoll.c29
1 files changed, 25 insertions, 4 deletions
diff --git a/usr/src/lib/libc/port/sys/epoll.c b/usr/src/lib/libc/port/sys/epoll.c
index 93379b583e..543856b2ec 100644
--- a/usr/src/lib/libc/port/sys/epoll.c
+++ b/usr/src/lib/libc/port/sys/epoll.c
@@ -10,7 +10,7 @@
*/
/*
- * Copyright (c) 2014, Joyent, Inc. All rights reserved.
+ * Copyright 2016 Joyent, Inc.
*/
#include <sys/types.h>
@@ -114,7 +114,7 @@ epoll_ctl(int epfd, int op, int fd, struct epoll_event *event)
{
dvpoll_epollfd_t epoll[2];
uint32_t events, ev = 0;
- int i = 0;
+ int i = 0, res;
epoll[i].dpep_pollfd.fd = fd;
@@ -165,8 +165,29 @@ epoll_ctl(int epfd, int op, int fd, struct epoll_event *event)
}
epoll[i].dpep_pollfd.events = ev;
-
- return (write(epfd, epoll, sizeof (epoll[0]) * (i + 1)) == -1 ? -1 : 0);
+retry:
+ res = write(epfd, epoll, sizeof (epoll[0]) * (i + 1));
+
+ if (res == -1) {
+ if (errno == EINTR) {
+ /*
+ * Linux does not document EINTR as an allowed error
+ * for epoll_ctl. The write must be retried if it is
+ * not done automatically via SA_RESTART.
+ */
+ goto retry;
+ }
+ if (errno == ELOOP) {
+ /*
+ * Convert the specific /dev/poll error about an fd
+ * loop into what is expected from the Linux epoll
+ * interface.
+ */
+ errno = EINVAL;
+ }
+ return (-1);
+ }
+ return (0);
}
int