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.
This commit is contained in:
Willy Tarreau 2024-12-04 15:58:49 +01:00 committed by William Lallemand
parent 70e4938aec
commit 8b16b72541

View file

@ -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.