If evsel->del() fails, don't leave the evmap in an inconsistent state.

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.
This commit is contained in:
Maxime Henrion 2013-05-16 16:38:39 +00:00 committed by Nick Mathewson
parent 8ab612e396
commit 9b5a527f5b

View File

@ -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;