From 56894db00056199c903b1ec3336909be9bc5625f Mon Sep 17 00:00:00 2001 From: Valentine Krasnobaeva Date: Fri, 22 Nov 2024 23:11:05 +0100 Subject: [PATCH] MINOR: startup: keep updating verbosity modes only in haproxy.c This commit prepares the move of mworker_run_master() in mworker.c. Let's remove from it's definition the code, which adjusts verbosity in dependency of other global run time modes (daemon or foreground). This part should stay in main(), where all verbosity modes are handeled for different mode combinations. --- src/haproxy.c | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/src/haproxy.c b/src/haproxy.c index f8d987ff2..e67315804 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -1964,14 +1964,6 @@ static void mworker_run_master() { struct mworker_proc *child, *it; - if ((!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE)) && - (global.mode & MODE_DAEMON)) { - /* detach from the tty, this is required to properly daemonize. */ - if ((getenv("HAPROXY_MWORKER_REEXEC") == NULL)) - stdio_quiet(-1); - global.mode &= ~MODE_VERBOSE; - global.mode |= MODE_QUIET; /* ensure that we won't say anything from now */ - } proc_self->failedreloads = 0; /* reset the number of failure */ mworker_loop(); #if defined(USE_OPENSSL) && !defined(OPENSSL_NO_DH) @@ -3013,6 +3005,17 @@ static void run_master_in_recovery_mode(int argc, char **argv) } step_init_4(); + + /* set quiet mode if MODE_DAEMON */ + if ((!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE)) && + (global.mode & MODE_DAEMON)) { + /* detach from the tty, this is required to properly daemonize. */ + if ((getenv("HAPROXY_MWORKER_REEXEC") == NULL)) + stdio_quiet(-1); + global.mode &= ~MODE_VERBOSE; + global.mode |= MODE_QUIET; /* ensure that we won't say anything from now */ + } + /* enter in master polling loop */ mworker_run_master(); } @@ -3846,6 +3849,15 @@ int main(int argc, char **argv) /* Master enters in its polling loop */ if (master) { + /* set quiet mode if MODE_DAEMON */ + if ((!(global.mode & MODE_QUIET) || (global.mode & MODE_VERBOSE)) && + (global.mode & MODE_DAEMON)) { + /* detach from the tty, this is required to properly daemonize. */ + if ((getenv("HAPROXY_MWORKER_REEXEC") == NULL)) + stdio_quiet(-1); + global.mode &= ~MODE_VERBOSE; + global.mode |= MODE_QUIET; /* ensure that we won't say anything from now */ + } mworker_run_master(); /* never get there in master context */ }