]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
BUG/MINOR: mworker: mworker_reexec: unset MODE_STARTING before free startup logs...
authorValentine Krasnobaeva <vkrasnobaeva@haproxy.com>
Sat, 26 Oct 2024 21:02:38 +0000 (23:02 +0200)
committerWilliam Lallemand <wlallemand@haproxy.com>
Tue, 29 Oct 2024 17:17:49 +0000 (18:17 +0100)
Flag MODE_STARTING should be unset for master just before freeing the startup
logs ring, as it triggers the copy of process logs to this ring, see the code
of print_message().

Moreover with this flag set, if startup logs ring pointer is NULL, any
print_message() triggered just before the execvp in mworker_reexec() will call
startup_logs_init(). So ring will be allocated again "discretely" and after
execvp we will lost its address, as in step_init_1() we will call again
startup_logs_init().

No need to backport this fix as it's related to the latest master-worker
refactoring.

src/haproxy.c

index 0b4bab472b5b724575970399f63797826b1054a7..bef1c46ca43d82d0142fc66c2767c33272c5a34a 100644 (file)
@@ -749,8 +749,6 @@ static void mworker_reexec(int hardreload)
 
        mworker_proc_list_to_env(); /* put the children description in the env */
 
-       startup_logs_free(startup_logs);
-
        /* during the reload we must ensure that every FDs that can't be
         * reuse (ie those that are not referenced in the proc_list)
         * are closed or they will leak. */
@@ -832,6 +830,12 @@ static void mworker_reexec(int hardreload)
        for (i = 1; i < old_argc; i++)
                next_argv[next_argc++] = old_argv[i];
 
+       /* need to withdraw MODE_STARTING from master, because we have to free
+        * the startup logs ring here, see more details in print_message()
+        */
+       global.mode &= ~MODE_STARTING;
+       startup_logs_free(startup_logs);
+
        signal(SIGPROF, SIG_IGN);
        execvp(next_argv[0], next_argv);
        ha_warning("Failed to reexecute the master process [%d]: %s\n", pid, strerror(errno));