summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPatrick Mooney <pmooney@pfmooney.com>2016-06-09 20:06:25 +0000
committerPatrick Mooney <pmooney@pfmooney.com>2016-06-09 20:54:26 +0000
commit3a73555a6bf9a4594d44713855d2396974e5f9ad (patch)
tree74ebf750da93fc94438d21646bb2aa4314e9590b
parentff1e61db511fa5cb72976825e26c820fdc37f544 (diff)
downloadillumos-joyent-3a73555a6bf9a4594d44713855d2396974e5f9ad.tar.gz
OS-5459 epoll_ctl should throw EINVAL for loops
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
-rw-r--r--usr/src/lib/libc/port/sys/epoll.c20
1 files changed, 16 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..b8992e064b 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,20 @@ 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);
+ res = write(epfd, epoll, sizeof (epoll[0]) * (i + 1));
+
+ if (res == -1) {
+ 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