diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-11-03 11:04:46 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2021-11-03 11:29:49 +0100 |
commit | 4bf4f50faabd9014720e3e499801d4cdb1e32f6d (patch) | |
tree | 4d5b6fb1fa9d903c63653c879c003698a66ff597 /src/machine/machined.c | |
parent | 9214f2999b85533ad184e6508f0a0a078d9d3b8f (diff) | |
download | systemd-4bf4f50faabd9014720e3e499801d4cdb1e32f6d.tar.gz |
tree-wide: warn when sd_notify fails with READY=1 or FDSTOREREMOVE=1
Most sd_notify() calls are like log_info() — the result is only informative
and if they fail, it's best ignore this. But if a call with READY=1 fails,
the unit may enter a failed state, so we should warn about this. Similarly
for FSTOREREMOVE=1: the manager may be left with a stale fd, at least wasting
resources.
Diffstat (limited to 'src/machine/machined.c')
-rw-r--r-- | src/machine/machined.c | 14 |
1 files changed, 5 insertions, 9 deletions
diff --git a/src/machine/machined.c b/src/machine/machined.c index 241be42c91..4ab459d3ca 100644 --- a/src/machine/machined.c +++ b/src/machine/machined.c @@ -6,14 +6,13 @@ #include <sys/types.h> #include <unistd.h> -#include "sd-daemon.h" - #include "alloc-util.h" #include "bus-error.h" #include "bus-locator.h" #include "bus-log-control-api.h" #include "bus-polkit.h" #include "cgroup-util.h" +#include "daemon-util.h" #include "dirent-util.h" #include "discover-image.h" #include "fd-util.h" @@ -352,17 +351,14 @@ static int run(int argc, char *argv[]) { return log_error_errno(r, "Failed to fully start up daemon: %m"); log_debug("systemd-machined running as pid "PID_FMT, getpid_cached()); - (void) sd_notify(false, - "READY=1\n" - "STATUS=Processing requests..."); + r = sd_notify(false, NOTIFY_READY); + if (r < 0) + log_warning_errno(r, "Failed to send readiness notification, ignoring: %m"); r = manager_run(m); + (void) sd_notify(false, NOTIFY_STOPPING); log_debug("systemd-machined stopped as pid "PID_FMT, getpid_cached()); - (void) sd_notify(false, - "STOPPING=1\n" - "STATUS=Shutting down..."); - return r; } |