diff options
author | Azat Khuzhin <azat@libevent.org> | 2020-05-05 00:21:18 +0300 |
---|---|---|
committer | Azat Khuzhin <azat@libevent.org> | 2020-05-05 00:25:23 +0300 |
commit | 972b456bf60e9a2f550ec45a14921c06e252c793 (patch) | |
tree | 1a2618212597dd1f9919f68a22612564320ed7d1 /epoll.c | |
parent | c10cde4c617979e951352775a9685a47bf9c6acd (diff) | |
download | libevent-972b456bf60e9a2f550ec45a14921c06e252c793.tar.gz |
Fix EV_CLOSED detection/reporting (epoll only)
- EV_CLOSED is EPOLLRDHUP in epoll
- EPOLLRDHUP reported w/o EPOLLHUP if the socket closed with shutdown(SHUT_WR)
- EPOLLRDHUP reported w/ EPOLLHUP if the socket closed with close()
so in this case epoll backend will detect this event as error
(EV_READ|EV_WRITE), since the epoll_ctl() will return EPOLLRDHUP with
EPOLLHUP set, but this is not correct, let's fix this.
Fixes: #984
Diffstat (limited to 'epoll.c')
-rw-r--r-- | epoll.c | 4 |
1 files changed, 3 insertions, 1 deletions
@@ -487,7 +487,9 @@ epoll_dispatch(struct event_base *base, struct timeval *tv) continue; #endif - if (what & (EPOLLHUP|EPOLLERR)) { + if (what & EPOLLERR) { + ev = EV_READ | EV_WRITE; + } else if ((what & EPOLLHUP) && !(what & EPOLLRDHUP)) { ev = EV_READ | EV_WRITE; } else { if (what & EPOLLIN) |