Skip to content

Commit

Permalink
BUG/MINOR: init: do not call fork_poller() for non-forked processes
Browse files Browse the repository at this point in the history
In 3.1-dev10, commit 8dd4efe ("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.
  • Loading branch information
wtarreau authored and wlallemand committed Dec 4, 2024
1 parent 70e4938 commit 8b16b72
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/haproxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 8b16b72

Please sign in to comment.