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.
This commit is contained in:
William Lallemand 2022-12-07 15:03:55 +01:00
parent 5fa29b8a74
commit 40db4ae8bb

View File

@ -877,6 +877,17 @@ void reexec_on_failure()
mworker_reexec_waitmode(); 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 * 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; global.mode &= ~MODE_MWORKER;
} }
if ((global.mode & (MODE_MWORKER | MODE_CHECK | MODE_CHECK_CONDITION)) == MODE_MWORKER && /* set the atexit functions when not doing configuration check */
(getenv("HAPROXY_MWORKER_REEXEC") != NULL)) { if (!(global.mode & (MODE_CHECK | MODE_CHECK_CONDITION))
atexit_flag = 1; && (getenv("HAPROXY_MWORKER_REEXEC") != NULL)) {
atexit(reexec_on_failure);
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) { if (change_dir && chdir(change_dir) < 0) {