From a0d727e0698d8b5f201667ffcd857824285b90d7 Mon Sep 17 00:00:00 2001 From: Valentine Krasnobaeva Date: Wed, 23 Oct 2024 15:46:54 +0200 Subject: [PATCH] CLEANUP: mworker: clean mworker_reexec 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 | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/haproxy.c b/src/haproxy.c index 534f5a404c..2058d7ca63 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -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