]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: polling: make epoll and kqueue not depend on maxfd anymore
authorWilly Tarreau <w@1wt.eu>
Mon, 29 Jan 2018 13:58:02 +0000 (14:58 +0100)
committerWilly Tarreau <w@1wt.eu>
Mon, 29 Jan 2018 14:18:54 +0000 (15:18 +0100)
Maxfd is really only useful to poll() and select(), yet epoll and
kqueue reference it almost by mistake :
  - cloning of the initial FDs (maxsock should be used here)
  - max polled events, it's maxpollevents which should be used here.

Let's fix these places.

src/ev_epoll.c
src/ev_kqueue.c
src/fd.c

index e5c0001c95e68637cc87f8b8c066f2d55f72030b..baa677018142b76087d9ab67fcc01112789b4772 100644 (file)
@@ -206,7 +206,7 @@ static int init_epoll_per_thread()
         * fd for this thread. Let's just mark them as updated, the poller will
         * do the rest.
         */
-       for (fd = 0; fd < maxfd; fd++)
+       for (fd = 0; fd < global.maxsock; fd++)
                updt_fd_polling(fd);
 
        return 1;
index 86731af88be4c914a1ad0dda4e9aa9fccd65db28..0346ec4ef17d73db4ffdbbd1fae0993cd2665cdb 100644 (file)
@@ -110,7 +110,7 @@ REGPRM2 static void _do_poll(struct poller *p, int exp)
        else
                activity[tid].poll_exp++;
 
-       fd = MIN(maxfd, global.tune.maxpollevents);
+       fd = global.tune.maxpollevents;
        gettimeofday(&before_poll, NULL);
        status = kevent(kqueue_fd[tid], // int kq
                        NULL,      // const struct kevent *changelist
@@ -172,7 +172,7 @@ static int init_kqueue_per_thread()
         * fd for this thread. Let's just mark them as updated, the poller will
         * do the rest.
         */
-       for (fd = 0; fd < maxfd; fd++)
+       for (fd = 0; fd < global.maxsock; fd++)
                updt_fd_polling(fd);
 
        return 1;
index b64130ed0a1e5c4c1e44670c2cab28ea3cde9a35..4397f6e31b1864abde5f8503c7479b282033ced4 100644 (file)
--- a/src/fd.c
+++ b/src/fd.c
@@ -457,7 +457,7 @@ int list_pollers(FILE *out)
 int fork_poller()
 {
        int fd;
-       for (fd = 0; fd <= maxfd; fd++) {
+       for (fd = 0; fd < global.maxsock; fd++) {
                if (fdtab[fd].owner) {
                        fdtab[fd].cloned = 1;
                }