mirror of
https://github.com/systemd/systemd.git
synced 2026-11-06 05:17:24 +00:00
mountfsd: stop when the worker binary cannot be executed
If systemd-mountwork cannot be executed, every worker fails immediately, and on_worker_exit() spawns a new one each time, until the rate limit is hit. Let the worker exit with EXIT_EXEC in that case, and exit the manager instead of respawning workers that fail the same way. Resource exhaustion (ENOMEM, EMFILE, ENFILE) is likely transient, so in that case the worker still exits with EXIT_FAILURE and is respawned as before. (cherry picked from commite4b7e3763d) (cherry picked from commitc47263b5a6)
This commit is contained in:
1 parent
b7c8f5fd15
commit
bdeb98c736
1 file changed
+11
-1
@@ -9,7 +9,9 @@
|
||||
#include "build-path.h"
|
||||
#include "common-signal.h"
|
||||
#include "env-util.h"
|
||||
#include "errno-util.h"
|
||||
#include "event-util.h"
|
||||
#include "exit-status.h"
|
||||
#include "fd-util.h"
|
||||
#include "format-util.h"
|
||||
#include "log.h"
|
||||
@@ -43,6 +45,14 @@ static int on_worker_exit(sd_event_source *s, const siginfo_t *si, void *userdat
|
||||
sd_event_source_disable_unref(s);
|
||||
|
||||
if (si->si_code == CLD_EXITED) {
|
||||
if (si->si_status == EXIT_EXEC) {
|
||||
/* The worker binary cannot be executed, respawning it would just fail the same way
|
||||
* over and over again. Let's give up. */
|
||||
log_error("Worker " PID_FMT " failed to execute worker binary, exiting.", si->si_pid);
|
||||
sd_event_exit(m->event, EXIT_FAILURE);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (si->si_status == EXIT_SUCCESS)
|
||||
log_debug("Worker " PID_FMT " exited successfully.", si->si_pid);
|
||||
else
|
||||
@@ -194,7 +204,7 @@ static int start_one_worker(Manager *m) {
|
||||
|
||||
r = invoke_callout_binary(SYSTEMD_MOUNTWORK_PATH, STRV_MAKE("systemd-mountwork", "xxxxxxxxxxxxxxxx")); /* With some extra space rename_process() can make use of */
|
||||
log_error_errno(r, "Failed to start worker process: %m");
|
||||
_exit(EXIT_FAILURE);
|
||||
_exit(ERRNO_IS_NEG_RESOURCE(r) ? EXIT_FAILURE : EXIT_EXEC);
|
||||
}
|
||||
|
||||
r = event_add_child_pidref(m->event, &source, &pidref, WEXITED, on_worker_exit, m);
|
||||
|
||||
Reference in new issue
Block a user