]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
CLEANUP: mworker: clean mworker_reexec
authorValentine Krasnobaeva <vkrasnobaeva@haproxy.com>
Wed, 23 Oct 2024 13:46:54 +0000 (15:46 +0200)
committerWilliam Lallemand <wlallemand@haproxy.com>
Thu, 24 Oct 2024 09:32:20 +0000 (11:32 +0200)
Before refactoring master-worker architecture, resources to setup master CLI
for the new worker process (shared sockpair, entry in proc_list) were created
in init() before parsing the configuration and binding listening sockets. So,
master during its re-exec has had to cleanup the new worker's ressources in
a case, when it fails at some initialization step before the fork.

Now fork happens very early and worker parses its configuration by itself. If
it fails during the initialization stage, all clean ups (deleting the fds of
the shared sockpair, proc_list cleanup) are performed in SIGCHLD handler up to
catching the SIGCHLD corresponded to this new worker. So, there is no longer
need to call mworker_cleanup_proc() in mworker_reexec().

As for mworker_cleanlisteners(), there is no longer need to call this function.
Master parses now only "global" and "program" sections, so it allocates only
MASTER proxy, which is stopped in mworker_reexec() by mworker_cli_proxy_stop().

Let's keep the definitions of mworker_cleanlisteners() and
mworker_cleanup_proc() in mworker.c for the moment. We may reuse parts of its
code later.

src/haproxy.c

index 534f5a404c2c695e361e686dd4943026192f6ab2..2058d7ca63e77f07e8a6228be35e88cb0081b957 100644 (file)
@@ -747,12 +747,8 @@ static void mworker_reexec(int hardreload)
 
        setenv("HAPROXY_MWORKER_REEXEC", "1", 1);
 
-       mworker_cleanup_proc();
        mworker_proc_list_to_env(); /* put the children description in the env */
 
-       /* ensure that we close correctly every listeners before reexecuting */
-       mworker_cleanlisteners();
-
        startup_logs_free(startup_logs);
 
        /* during the reload we must ensure that every FDs that can't be