]> git.ipfire.org Git - thirdparty/haproxy.git/commit
MAJOR: mworker: move master-worker fork in init()
authorValentine Krasnobaeva <vkrasnobaeva@haproxy.com>
Fri, 28 Jun 2024 14:21:30 +0000 (16:21 +0200)
committerWilly Tarreau <w@1wt.eu>
Wed, 16 Oct 2024 20:00:58 +0000 (22:00 +0200)
commit8dd4efe42fc16e3ad3c734483c0e7cc1dc8e5bbe
tree1e1d261135bb8fa74c0f775fd37c6459de71b52d
parent4cbfcc60f499328a6720b6b98b3be984a7fa5bb3
MAJOR: mworker: move master-worker fork in init()

This refactoring allows to simplify 'master-worker' logic. The master process
with this change will fork a worker very early at the initialization stage,
which allows to perform a configuration parsing only for the worker. In reality
only the worker process needs to parse and to apply the whole configuration.

Master process just polls master CLI sockets, watches worker status, catches
its termination state and handles the signals. With this refactoring there is
no longer need for master to perform re-execution after reading the whole
configuration file to free additional memory. And there is no longer need for
worker to register atexit callbacks, in order to free the memory, when it
fails to apply the new configuration. In contrast, we now need to set
proc_self pointer to the new worker entry in processes list just after
the fork in the worker process context. proc_self is dereferenced in
mworker_sockpair_register_per_thread(), which is called when worker enters in
its polling loop.

Following patches will try to gather more 'worker' and 'master' specific' code
in the dedicated cases of this new fork() switch, or in a separate functions.
src/haproxy.c