From: Willy Tarreau Date: Wed, 4 Dec 2024 14:58:49 +0000 (+0100) Subject: BUG/MINOR: init: do not call fork_poller() for non-forked processes X-Git-Tag: v3.2-dev1~49 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=8b16b725411d72d3bab184bcd0c0253dddeedeb1;p=thirdparty%2Fhaproxy.git BUG/MINOR: init: do not call fork_poller() for non-forked processes In 3.1-dev10, commit 8dd4efe42f ("MAJOR: mworker: move master-worker fork in init()") made the fork_poller() code unconditional, while it is only desirable for processes that have been forked from a parent (standalone daemon mode) or from a master (master-worker mode). The call can be expensive in some cases as it will create a new poller, scan and try to migrate to it all existing FDs till the highest known one. With very high numbers of FDs, this can take several seconds to start. This should be backported to 3.1. --- diff --git a/src/haproxy.c b/src/haproxy.c index c3538748c6..eac6329a1e 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -3603,7 +3603,14 @@ int main(int argc, char **argv) devnullfd = -1; } pid = getpid(); /* update pid */ - fork_poller(); + + /* This call is expensive, as it creates a new poller, scans and tries + * to migrate to it all existing FDs until the highest known one. With + * very high numbers of FDs, this can take several seconds to start. + * So, it's only desirable for modes, when we perform a fork(). + */ + if (global.mode & MODE_DAEMON) + fork_poller(); /* pass through every cli socket, and check if it's bound to * the current process and if it exposes listeners sockets.