From: William Lallemand Date: Wed, 7 Dec 2022 14:03:55 +0000 (+0100) Subject: MINOR: mworker: display an alert upon a wait-mode exit X-Git-Tag: v2.8-dev1~171 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=40db4ae8bb864adfebbd4529a3bae187974b3698;p=thirdparty%2Fhaproxy.git MINOR: mworker: display an alert upon a wait-mode exit 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. --- diff --git a/src/haproxy.c b/src/haproxy.c index 6076e0282d..0725261756 100644 --- a/src/haproxy.c +++ b/src/haproxy.c @@ -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) {