]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
MINOR: mworker: display an alert upon a wait-mode exit
authorWilliam Lallemand <wlallemand@haproxy.org>
Wed, 7 Dec 2022 14:03:55 +0000 (15:03 +0100)
committerWilliam Lallemand <wlallemand@haproxy.org>
Wed, 7 Dec 2022 14:07:53 +0000 (15:07 +0100)
When the mworker wait mode fails it does an exit, but there is no
error message which says it exits.

Add a message which specify that the error is non-recoverable.

Could be backported in 2.7 and possibly earlier branch.

src/haproxy.c

index 6076e0282db19765ee4d1709a3d9fd9104070e71..072526175615a2d24d807165488c4bd0aa5e2e62 100644 (file)
@@ -877,6 +877,17 @@ void reexec_on_failure()
        mworker_reexec_waitmode();
 }
 
+/*
+ * Exit with an error message upon a wait-mode failure.
+ */
+void exit_on_waitmode_failure()
+{
+       if (!atexit_flag)
+               return;
+
+       ha_alert("Non-recoverable mworker wait-mode error, exiting.\n");
+}
+
 
 /*
  * upon SIGUSR1, let's have a soft stop. Note that soft_stop() broadcasts
@@ -1970,10 +1981,17 @@ static void init(int argc, char **argv)
                global.mode &= ~MODE_MWORKER;
        }
 
-       if ((global.mode & (MODE_MWORKER | MODE_CHECK | MODE_CHECK_CONDITION)) == MODE_MWORKER &&
-           (getenv("HAPROXY_MWORKER_REEXEC") != NULL)) {
-               atexit_flag = 1;
-               atexit(reexec_on_failure);
+       /* set the atexit functions when not doing configuration check */
+       if (!(global.mode & (MODE_CHECK | MODE_CHECK_CONDITION))
+           && (getenv("HAPROXY_MWORKER_REEXEC") != NULL)) {
+
+               if (global.mode & MODE_MWORKER) {
+                       atexit_flag = 1;
+                       atexit(reexec_on_failure);
+               } else if (global.mode & MODE_MWORKER_WAIT) {
+                       atexit_flag = 1;
+                       atexit(exit_on_waitmode_failure);
+               }
        }
 
        if (change_dir && chdir(change_dir) < 0) {