mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-10-27 10:25:06 +03:00
service: Display updated WatchdogUSec from sd_notify
Suppose a service has WatchdogSec set to 2 seconds in its unit file. I then start the service and WatchdogUSec is set correctly: % systemctl --user show psi-notify -p WatchdogUSec WatchdogUSec=2s Now I call `sd_notify(0, "WATCHDOG_USEC=10000000")`. The new timer seems to have taken effect, since I only send `WATCHDOG=1` every 4 seconds, and systemd isn't triggering the watchdog handler. However, `systemctl show` still shows WatchdogUSec as 2s: % systemctl --user show psi-notify -p WatchdogUSec WatchdogUSec=2s This seems surprising, since this "original" watchdog timer isn't the one taking effect any more. This patch makes it so that we instead display the new watchdog timer after sd_notify(WATCHDOG_USEC): % systemctl --user show psi-notify -p WatchdogUSec WatchdogUSec=10s Fixes #15726.
This commit is contained in:
parent
2991fa41e4
commit
4793c31083
@ -28,6 +28,7 @@ static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_restart, service_restart, Servi
|
||||
static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_notify_access, notify_access, NotifyAccess);
|
||||
static BUS_DEFINE_PROPERTY_GET_ENUM(property_get_emergency_action, emergency_action, EmergencyAction);
|
||||
static BUS_DEFINE_PROPERTY_GET(property_get_timeout_abort_usec, "t", Service, service_timeout_abort_usec);
|
||||
static BUS_DEFINE_PROPERTY_GET(property_get_watchdog_usec, "t", Service, service_get_watchdog_usec);
|
||||
|
||||
static int property_get_exit_status_set(
|
||||
sd_bus *bus,
|
||||
@ -101,7 +102,7 @@ const sd_bus_vtable bus_service_vtable[] = {
|
||||
SD_BUS_PROPERTY("TimeoutStopUSec", "t", bus_property_get_usec, offsetof(Service, timeout_stop_usec), SD_BUS_VTABLE_PROPERTY_CONST),
|
||||
SD_BUS_PROPERTY("TimeoutAbortUSec", "t", property_get_timeout_abort_usec, 0, 0),
|
||||
SD_BUS_PROPERTY("RuntimeMaxUSec", "t", bus_property_get_usec, offsetof(Service, runtime_max_usec), SD_BUS_VTABLE_PROPERTY_CONST),
|
||||
SD_BUS_PROPERTY("WatchdogUSec", "t", bus_property_get_usec, offsetof(Service, watchdog_usec), SD_BUS_VTABLE_PROPERTY_CONST),
|
||||
SD_BUS_PROPERTY("WatchdogUSec", "t", property_get_watchdog_usec, 0, 0),
|
||||
BUS_PROPERTY_DUAL_TIMESTAMP("WatchdogTimestamp", offsetof(Service, watchdog_timestamp), 0),
|
||||
SD_BUS_PROPERTY("PermissionsStartOnly", "b", bus_property_get_bool, offsetof(Service, permissions_start_only), SD_BUS_VTABLE_PROPERTY_CONST|SD_BUS_VTABLE_HIDDEN), /* 😷 deprecated */
|
||||
SD_BUS_PROPERTY("RootDirectoryStartOnly", "b", bus_property_get_bool, offsetof(Service, root_directory_start_only), SD_BUS_VTABLE_PROPERTY_CONST),
|
||||
|
@ -198,15 +198,6 @@ static void service_stop_watchdog(Service *s) {
|
||||
s->watchdog_timestamp = DUAL_TIMESTAMP_NULL;
|
||||
}
|
||||
|
||||
static usec_t service_get_watchdog_usec(Service *s) {
|
||||
assert(s);
|
||||
|
||||
if (s->watchdog_override_enable)
|
||||
return s->watchdog_override_usec;
|
||||
|
||||
return s->watchdog_original_usec;
|
||||
}
|
||||
|
||||
static void service_start_watchdog(Service *s) {
|
||||
usec_t watchdog_usec;
|
||||
int r;
|
||||
|
@ -200,6 +200,11 @@ static inline usec_t service_timeout_abort_usec(Service *s) {
|
||||
return s->timeout_abort_set ? s->timeout_abort_usec : s->timeout_stop_usec;
|
||||
}
|
||||
|
||||
static inline usec_t service_get_watchdog_usec(Service *s) {
|
||||
assert(s);
|
||||
return s->watchdog_override_enable ? s->watchdog_override_usec : s->watchdog_original_usec;
|
||||
}
|
||||
|
||||
extern const UnitVTable service_vtable;
|
||||
|
||||
int service_set_socket_fd(Service *s, int fd, struct Socket *socket, bool selinux_context_net);
|
||||
|
Loading…
Reference in New Issue
Block a user