summaryrefslogtreecommitdiff
path: root/poll.c
diff options
context:
space:
mode:
authorTim Hentenaar <tim@hentenaar.com>2016-07-14 15:45:01 +0200
committerAzat Khuzhin <a3at.mail@gmail.com>2016-11-04 03:28:08 +0300
commit675974ce30591e9cdbebeead65e63eec9772ee90 (patch)
tree660f8f6be2f9d99c1f1c84ea82bec691dde05229 /poll.c
parent9ac000c724d208ed03f446539259424a5d6c96c2 (diff)
downloadlibevent-675974ce30591e9cdbebeead65e63eec9772ee90.tar.gz
poll: Prevent libevent from spinning if POLLNVAL occurs
This can happen, for example if libevent is being used to poll fds given by another library where the other library closes the fds without notifying the program using it that said fds were closed. In this case, libevent will simply spin on poll() since there are active fds, but won't call any event callback to handle the condition. In epoll case after socket closed it automatically removed from epfd, so IOW it will not spin in epoll* API, just a timeout. Fixes: #379
Diffstat (limited to 'poll.c')
-rw-r--r--poll.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/poll.c b/poll.c
index 51475934..fe440711 100644
--- a/poll.c
+++ b/poll.c
@@ -198,7 +198,7 @@ poll_dispatch(struct event_base *base, struct timeval *tv)
res = 0;
/* If the file gets closed notify */
- if (what & (POLLHUP|POLLERR))
+ if (what & (POLLHUP|POLLERR|POLLNVAL))
what |= POLLIN|POLLOUT;
if (what & POLLIN)
res |= EV_READ;