From d63eda1a3361027776f505e5db592e14f9620890 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Sun, 9 Nov 2014 13:32:28 +0100 Subject: [PATCH] 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. --- ucw/mainloop.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) 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 -- 2.39.2