Skip to content

Commit

Permalink
Epoll ET setting lost with multiple events for same fd
Browse files Browse the repository at this point in the history
After two or more events have been registered for the same file
descriptor using EV_ET, if one of the events is deleted, then the
epoll_ctl() call issued by libevent drops the EPOLLET flag resulting in
level triggered notifications.

[ azat: use existing "et" in the evmap_io_del_() ]
  • Loading branch information
ikouvelas authored and azat committed Oct 30, 2018
1 parent 77c0e51 commit b77d3e7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
9 changes: 6 additions & 3 deletions epoll.c
Original file line number Diff line number Diff line change
Expand Up @@ -401,11 +401,14 @@ epoll_nochangelist_del(struct event_base *base, evutil_socket_t fd,
ch.old_events = old;
ch.read_change = ch.write_change = ch.close_change = 0;
if (events & EV_WRITE)
ch.write_change = EV_CHANGE_DEL;
ch.write_change = EV_CHANGE_DEL |
(events & EV_ET);
if (events & EV_READ)
ch.read_change = EV_CHANGE_DEL;
ch.read_change = EV_CHANGE_DEL |
(events & EV_ET);
if (events & EV_CLOSED)
ch.close_change = EV_CHANGE_DEL;
ch.close_change = EV_CHANGE_DEL |
(events & EV_ET);

return epoll_apply_one_change(base, base->evbase, &ch);
}
Expand Down
3 changes: 2 additions & 1 deletion evmap.c
Original file line number Diff line number Diff line change
Expand Up @@ -393,7 +393,8 @@ evmap_io_del_(struct event_base *base, evutil_socket_t fd, struct event *ev)

if (res) {
void *extra = ((char*)ctx) + sizeof(struct evmap_io);
if (evsel->del(base, ev->ev_fd, old, res, extra) == -1) {
if (evsel->del(base, ev->ev_fd,
old, (ev->ev_events & EV_ET) | res, extra) == -1) {
retval = -1;
} else {
retval = 1;
Expand Down

0 comments on commit b77d3e7

Please sign in to comment.