]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[BUG] don't call epoll_ctl() on closed sockets
authorWilly Tarreau <w@1wt.eu>
Sat, 28 Mar 2009 18:43:06 +0000 (19:43 +0100)
committerWilly Tarreau <w@1wt.eu>
Sat, 28 Mar 2009 18:43:06 +0000 (19:43 +0100)
Some I/O callbacks are able to close their socket themselves. We
want to check this before calling epoll_ctl(EPOLL_CTL_DEL), otherwise
we get a -1 EBADF. Right now is looks like this could not cause any
trouble but the case is racy enough to fix it.

src/ev_sepoll.c

index feca9670cb22af78f3f2c7db95d839fb51731e05..6a3c45913b6b37ececa27f64ad9cbd4b571daba1 100644 (file)
@@ -388,6 +388,10 @@ REGPRM2 static void _do_poll(struct poller *p, int exp)
                        fd_list[fd].e &= ~FD_EV_MASK_W;
                }
 
+               /* one callback might already have closed the fd by itself */
+               if (fdtab[fd].state == FD_STCLOSE)
+                       continue;
+
                /* Now, we will adjust the event in the poll list. Indeed, it
                 * is possible that an event which was previously in the poll
                 * list now goes out, and the opposite is possible too. We can