]> granicus.if.org Git - libevent/commitdiff
If evsel->del() fails, don't leave the evmap in an inconsistent state.
authorMaxime Henrion <mhenrion@appnexus.com>
Thu, 16 May 2013 16:38:39 +0000 (16:38 +0000)
committerNick Mathewson <nickm@torproject.org>
Fri, 17 May 2013 13:55:20 +0000 (09:55 -0400)
 This fixes assertion failures in cases where epoll() fails with EBADF
 -- the root cause for which is as of yet unknown. It seems something
 (OpenSSL?) is closing the file descriptor under our feet.

evmap.c

diff --git a/evmap.c b/evmap.c
index d2160fbea82eb70ff2fa8e50f26a09462daa058c..1e2f8b552b1b2121b4c3a3ace4305b5815cc2423 100644 (file)
--- a/evmap.c
+++ b/evmap.c
@@ -375,9 +375,11 @@ 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)
-                       return (-1);
-               retval = 1;
+               if (evsel->del(base, ev->ev_fd, old, res, extra) == -1) {
+                       retval = -1;
+               } else {
+                       retval = 1;
+               }
        }
 
        ctx->nread = nread;