]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: startup: keep updating verbosity modes only in haproxy.c
authorValentine Krasnobaeva <vkrasnobaeva@haproxy.com>
Fri, 22 Nov 2024 22:11:05 +0000 (23:11 +0100)
committerWilliam Lallemand <wlallemand@haproxy.com>
Mon, 25 Nov 2024 14:20:24 +0000 (15:20 +0100)
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

index f8d987ff21e1f388033265955d404ddc99821c85..e6731580433d4d2230adb26208015db74b4518a8 100644 (file)
@@ -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 */
        }