From: Willy Tarreau Date: Mon, 29 Jan 2018 13:58:02 +0000 (+0100) Subject: MINOR: polling: make epoll and kqueue not depend on maxfd anymore X-Git-Tag: v1.9-dev1~481 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ce036bc2daec3bb407f801f1bab366ee383b76b0;p=thirdparty%2Fhaproxy.git MINOR: polling: make epoll and kqueue not depend on maxfd anymore 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. --- diff --git a/src/ev_epoll.c b/src/ev_epoll.c index e5c0001c95..baa6770181 100644 --- a/src/ev_epoll.c +++ b/src/ev_epoll.c @@ -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; diff --git a/src/ev_kqueue.c b/src/ev_kqueue.c index 86731af88b..0346ec4ef1 100644 --- a/src/ev_kqueue.c +++ b/src/ev_kqueue.c @@ -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; diff --git a/src/fd.c b/src/fd.c index b64130ed0a..4397f6e31b 100644 --- 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; }