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.

(cherry picked from commit 40db4ae8bb864adfebbd4529a3bae187974b3698)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
(cherry picked from commit bb0ab9833adf1c871143d8555fedbb9ec1823f8a)
Signed-off-by: Christopher Faulet <cfaulet@haproxy.com>
This commit is contained in:
William Lallemand 2022-12-07 15:03:55 +01:00 committed by Christopher Faulet
parent 0ce2ac2a72
commit 06dc13be6b

View File

@ -880,6 +880,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
@ -1933,10 +1944,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) {