diff options
author | Stefan Metzmacher <metze@samba.org> | 2013-02-20 13:33:19 +0100 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2013-03-01 12:00:56 -0800 |
commit | 7ef688c1dd797b1d108afe02c4b803bab01988ab (patch) | |
tree | afc0a2289c32b76c521e4ee427fc3d43e369fc58 /lib/tevent | |
parent | 2721f0dc5b35aa4961d801c2377a951cd63ecee1 (diff) | |
download | samba-7ef688c1dd797b1d108afe02c4b803bab01988ab.tar.gz samba-7ef688c1dd797b1d108afe02c4b803bab01988ab.tar.bz2 samba-7ef688c1dd797b1d108afe02c4b803bab01988ab.zip |
tevent: ignore EBADF from epoll_ctl() and disable the event
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'lib/tevent')
-rw-r--r-- | lib/tevent/tevent_epoll.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/lib/tevent/tevent_epoll.c b/lib/tevent/tevent_epoll.c index 0f7080c6e1..adea677096 100644 --- a/lib/tevent/tevent_epoll.c +++ b/lib/tevent/tevent_epoll.c @@ -278,7 +278,15 @@ static void epoll_add_event(struct epoll_event_context *epoll_ev, struct tevent_ event.events = epoll_map_flags(fde->flags); event.data.ptr = fde; ret = epoll_ctl(epoll_ev->epoll_fd, EPOLL_CTL_ADD, fde->fd, &event); - if (ret != 0) { + if (ret != 0 && errno == EBADF) { + tevent_debug(epoll_ev->ev, TEVENT_DEBUG_ERROR, + "EPOLL_CTL_ADD EBADF for " + "fde[%p] fd[%d] - disabling\n", + fde, fde->fd); + DLIST_REMOVE(epoll_ev->ev->fd_events, fde); + fde->event_ctx = NULL; + return; + } else if (ret != 0) { epoll_panic(epoll_ev, "EPOLL_CTL_ADD failed", false); return; } @@ -312,6 +320,14 @@ static void epoll_del_event(struct epoll_event_context *epoll_ev, struct tevent_ "EPOLL_CTL_DEL ignoring ENOENT for fd[%d]\n", fde->fd); return; + } else if (ret != 0 && errno == EBADF) { + tevent_debug(epoll_ev->ev, TEVENT_DEBUG_WARNING, + "EPOLL_CTL_DEL EBADF for " + "fde[%p] fd[%d] - disabling\n", + fde, fde->fd); + DLIST_REMOVE(epoll_ev->ev->fd_events, fde); + fde->event_ctx = NULL; + return; } else if (ret != 0) { epoll_panic(epoll_ev, "EPOLL_CTL_DEL failed", false); return; @@ -333,7 +349,15 @@ static void epoll_mod_event(struct epoll_event_context *epoll_ev, struct tevent_ event.events = epoll_map_flags(fde->flags); event.data.ptr = fde; ret = epoll_ctl(epoll_ev->epoll_fd, EPOLL_CTL_MOD, fde->fd, &event); - if (ret != 0) { + if (ret != 0 && errno == EBADF) { + tevent_debug(epoll_ev->ev, TEVENT_DEBUG_ERROR, + "EPOLL_CTL_MOD EBADF for " + "fde[%p] fd[%d] - disabling\n", + fde, fde->fd); + DLIST_REMOVE(epoll_ev->ev->fd_events, fde); + fde->event_ctx = NULL; + return; + } else if (ret != 0) { epoll_panic(epoll_ev, "EPOLL_CTL_MOD failed", false); return; } |