]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
OPTIM: epoll: current fd does not count as a new one
authorWilly Tarreau <w@1wt.eu>
Thu, 13 Dec 2012 23:02:33 +0000 (00:02 +0100)
committerWilly Tarreau <w@1wt.eu>
Thu, 13 Dec 2012 23:13:23 +0000 (00:13 +0100)
The epoll loop checks for newly appeared FDs in order to process them early
if they're accepted sockets. Since the introduction of the fd_ev_set()
calls before the iocb(), the current FD is always in the update list,
and we don't want to check it again, so we must assign the old_updt
index just before calling the I/O handler.

src/ev_epoll.c

index b858e18ae65bb7251bab58788e8aae640734f54b..5f7b7c3d7bb9fd5349f4d511e4504747057090f4 100644 (file)
@@ -167,7 +167,7 @@ REGPRM2 static void _do_poll(struct poller *p, int exp)
                fdtab[fd].ev |= n;
 
                if (fdtab[fd].iocb) {
-                       int new_updt, old_updt = fd_nbupdt; /* Save number of updates to detect creation of new FDs. */
+                       int new_updt, old_updt;
 
                        /* Mark the events as speculative before processing
                         * them so that if nothing can be done we don't need
@@ -179,6 +179,8 @@ REGPRM2 static void _do_poll(struct poller *p, int exp)
                        if (fdtab[fd].ev & FD_POLL_OUT)
                                fd_ev_set(fd, DIR_WR);
 
+                       /* Save number of updates to detect creation of new FDs. */
+                       old_updt = fd_nbupdt;
                        fdtab[fd].iocb(fd);
 
                        /* One or more fd might have been created during the iocb().