]> git.ozlabs.org Git - ccan/blobdiff - ccan/io/poll.c
io: handle errors on listening file descriptors.
[ccan] / ccan / io / poll.c
index 98a64f42fbe4336283be8f5371688da439943ac6..229f7ce9ab4e6fb9bf69ccfd7ae5b650a4463613 100644 (file)
@@ -282,9 +282,14 @@ void *io_loop(struct timers *timers, struct timer **expired)
                                break;
 
                        if (fds[i]->listener) {
+                               struct io_listener *l = (void *)fds[i];
                                if (events & POLLIN) {
-                                       accept_conn((void *)c);
+                                       accept_conn(l);
                                        r--;
+                               } else if (events & (POLLHUP|POLLNVAL|POLLERR)) {
+                                       r--;
+                                       errno = EBADF;
+                                       io_close_listener(l);
                                }
                        } else if (events & (POLLIN|POLLOUT)) {
                                r--;