]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: epoll: use a fix maxevents argument in epoll_wait()
authorWilly Tarreau <w@1wt.eu>
Fri, 18 Jan 2013 14:22:41 +0000 (15:22 +0100)
committerWilly Tarreau <w@1wt.eu>
Fri, 18 Jan 2013 14:31:03 +0000 (15:31 +0100)
epoll_wait() takes a number of returned events, not the number of
fds to consider. We must not pass it the number of the smallest fd,
as it leads to value zero being used, which is invalid in epoll_wait().
The effect may sometimes be observed with peers sections trying to
connect and causing 2-seconds CPU loops upon a soft reload because
epoll_wait() immediately returns -1 EINVAL instead of waiting for the
timeout to happen.

This fix should be backported to 1.4 too (into ev_epoll and ev_sepoll).

src/ev_epoll.c

index 034ec4c7d2f8c7b3abdb92af17f0d16797e08629..18abb107c7c4e7eea670cb036bccdf1c377b83f8 100644 (file)
@@ -133,9 +133,8 @@ REGPRM2 static void _do_poll(struct poller *p, int exp)
 
        /* now let's wait for polled events */
 
-       fd = MIN(maxfd, global.tune.maxpollevents);
        gettimeofday(&before_poll, NULL);
-       status = epoll_wait(epoll_fd, epoll_events, fd, wait_time);
+       status = epoll_wait(epoll_fd, epoll_events, global.tune.maxpollevents, wait_time);
        tv_update_date(wait_time, status);
        measure_idle();