diff --git a/src/uev.c b/src/uev.c index 1c71804..89d5e5a 100644 --- a/src/uev.c +++ b/src/uev.c @@ -26,6 +26,7 @@ #include /* O_CLOEXEC */ #include /* memset() */ #include +#include #include /* for select() workaround */ #include /* struct signalfd_siginfo */ #include /* close(), read() */ @@ -62,11 +63,15 @@ static int has_data(int fd) { struct timeval timeout = { 0, 0 }; fd_set fds; + int n = 0; FD_ZERO(&fds); FD_SET(fd, &fds); - return select(1, &fds, NULL, NULL, &timeout) > 0; + if (select(1, &fds, NULL, NULL, &timeout) > 0) + return ioctl(0, FIONREAD, &n) == 0 && n > 0; + + return 0; } /* Private to libuEv, do not use directly! */ @@ -292,7 +297,6 @@ int uev_run(uev_ctx_t *ctx, int flags) if (!has_data(w->fd)) { w->active = 0; LIST_REMOVE(w, link); - continue; } rerun++;