From c45d11cb30419959f2f5537bc4f0fa735e38b7a3 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Mon, 13 Nov 2017 18:06:09 +0100 Subject: [PATCH] service: reorder sd_notify() handling a bit Let's keep handling of WATCHDOG= and WATCHDOG_USEC= together. No functional changes. --- man/sd_notify.xml | 17 ++++++++--------- src/core/service.c | 18 +++++++++--------- src/systemd/sd-daemon.h | 10 +++++----- 3 files changed, 22 insertions(+), 23 deletions(-) diff --git a/man/sd_notify.xml b/man/sd_notify.xml index 078f1ff7e05..4a5e087af77 100644 --- a/man/sd_notify.xml +++ b/man/sd_notify.xml @@ -204,6 +204,14 @@ watchdog is enabled. + + WATCHDOG_USEC=… + + Reset watchdog_usec value during runtime. + Notice that this is not available when using sd_event_set_watchdog() + or sd_watchdog_enabled(). + Example : WATCHDOG_USEC=20000000 + FDSTORE=1 @@ -249,15 +257,6 @@ restrictions, it is ignored. - - WATCHDOG_USEC=… - - Reset watchdog_usec value during runtime. - Notice that this is not available when using sd_event_set_watchdog() - or sd_watchdog_enabled(). - Example : WATCHDOG_USEC=20000000 - - It is recommended to prefix variable names that are not diff --git a/src/core/service.c b/src/core/service.c index add054b7854..0beb25b8603 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -3457,6 +3457,15 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags, FDSet *fds) if (strv_find(tags, "WATCHDOG=1")) service_reset_watchdog(s); + e = strv_find_startswith(tags, "WATCHDOG_USEC="); + if (e) { + usec_t watchdog_override_usec; + if (safe_atou64(e, &watchdog_override_usec) < 0) + log_unit_warning(u, "Failed to parse WATCHDOG_USEC=%s", e); + else + service_reset_watchdog_timeout(s, watchdog_override_usec); + } + if (strv_find(tags, "FDSTORE=1")) { const char *name; @@ -3469,15 +3478,6 @@ static void service_notify_message(Unit *u, pid_t pid, char **tags, FDSet *fds) service_add_fd_store_set(s, fds, name); } - e = strv_find_startswith(tags, "WATCHDOG_USEC="); - if (e) { - usec_t watchdog_override_usec; - if (safe_atou64(e, &watchdog_override_usec) < 0) - log_unit_warning(u, "Failed to parse WATCHDOG_USEC=%s", e); - else - service_reset_watchdog_timeout(s, watchdog_override_usec); - } - /* Notify clients about changed status or main pid */ if (notify_dbus) unit_add_to_dbus_queue(u); diff --git a/src/systemd/sd-daemon.h b/src/systemd/sd-daemon.h index 61cfdd8e0a6..54e82562a76 100644 --- a/src/systemd/sd-daemon.h +++ b/src/systemd/sd-daemon.h @@ -204,17 +204,17 @@ int sd_is_mq(int fd, const char *path); timestamps to detect failed services. Also see sd_watchdog_enabled() below. + WATCHDOG_USEC=... + Reset watchdog_usec value during runtime. + To reset watchdog_usec value, start the service again. + Example: "WATCHDOG_USEC=20000000" + FDSTORE=1 Store the file descriptors passed along with the message in the per-service file descriptor store, and pass them to the main process again on next invocation. This variable is only supported with sd_pid_notify_with_fds(). - WATCHDOG_USEC=... - Reset watchdog_usec value during runtime. - To reset watchdog_usec value, start the service again. - Example: "WATCHDOG_USEC=20000000" - Daemons can choose to send additional variables. However, it is recommended to prefix variable names not listed above with X_.