From: Martin Mares Date: Sun, 9 Nov 2014 12:32:28 +0000 (+0100) Subject: Mainloop: Be benevolent when file_del() is called on a closed fd X-Git-Tag: v6.2~9 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=d63eda1a3361027776f505e5db592e14f9620890;p=libucw.git Mainloop: Be benevolent when file_del() is called on a closed fd I recently wrote a couple of wrappers for connecting other mainloop interfaces to UCW mainloop. Unfortunately, asking a mainloop to stop watching a file a moment after close() is a common (mal)practice. Working around it in the wrapper is hard to do, so I relax the checks in LibUCW instead. --- diff --git a/ucw/mainloop.c b/ucw/mainloop.c index 091b5f18..46604d86 100644 --- a/ucw/mainloop.c +++ b/ucw/mainloop.c @@ -360,7 +360,11 @@ file_del_ctx(struct main_context *m, struct main_file *fi) m->file_cnt--; #ifdef CONFIG_UCW_EPOLL if (m->epoll_fd >= 0 && epoll_ctl(m->epoll_fd, EPOLL_CTL_DEL, fi->fd, NULL) < 0) - die("epoll_ctl() failed: %m"); + { + // Some clients call file_del() on an already closed descriptor. Trying to be benevolent. + if (errno != EBADF) + die("epoll_ctl() failed: %m"); + } #else m->poll_table_obsolete = 1; #endif