BUG/MINOR: mworker: mworker_reexec: unset MODE_STARTING before free startup logs ring

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.
This commit is contained in:
Valentine Krasnobaeva 2024-10-26 23:02:38 +02:00 committed by William Lallemand
parent 984d2cfb61
commit cd57ee7ffa
1 changed files with 6 additions and 2 deletions

View 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));