mirror of
https://github.com/cuberite/libevent.git
synced 2025-08-03 09:16:30 -04:00
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 (cherry picked from commit 972b456bf60e9a2f550ec45a14921c06e252c793)
This commit is contained in:
parent
db2efdf55e
commit
1df324d4c4
4
epoll.c
4
epoll.c
@ -486,7 +486,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)
|
||||
|
@ -512,13 +512,8 @@ test_simpleclose(void *ptr)
|
||||
tt_assert(!event_base_loopexit(base, &tv));
|
||||
}
|
||||
|
||||
/* via close() */
|
||||
if (pair[1] == -1) {
|
||||
tt_int_op(event_base_loop(base, EVLOOP_NONBLOCK), ==, 0);
|
||||
} else {
|
||||
tt_int_op(event_base_loop(base, EVLOOP_NONBLOCK), ==, !persist);
|
||||
tt_int_op(got_event, ==, (events & ~EV_PERSIST));
|
||||
}
|
||||
tt_int_op(event_base_loop(base, EVLOOP_NONBLOCK), ==, !persist);
|
||||
tt_int_op(got_event, ==, (events & ~EV_PERSIST));
|
||||
|
||||
end:
|
||||
if (ev)
|
||||
|
Loading…
x
Reference in New Issue
Block a user