mirror of
https://github.com/systemd/systemd.git
synced 2026-08-05 23:50:42 +00:00
watchdog: Allow the watchdog to be disabled at runtime
manager_{get|set|override}_watchdog check the validity of the new
timeout or the overridden timeout values using timestamp_is_set which
does not recognize "0" as a valid value. However since f16890f, "0"
indicates a disabled watchdog and so is a value we should be able to
configure in order to disable the watchdog. A value of USEC_INFINITY is
considered a no-op. The behavior should be the same for all watchdog
timeout configurations (runtime, pretimeout, and shutdown).
This commit is contained in:
committed by
Luca Boccassi
parent
d8c7d6d4fe
commit
902ea119e2
@@ -3419,7 +3419,7 @@ usec_t manager_get_watchdog(Manager *m, WatchdogType t) {
|
||||
if (MANAGER_IS_USER(m))
|
||||
return USEC_INFINITY;
|
||||
|
||||
if (timestamp_is_set(m->watchdog_overridden[t]))
|
||||
if (m->watchdog_overridden[t] != USEC_INFINITY)
|
||||
return m->watchdog_overridden[t];
|
||||
|
||||
return m->watchdog[t];
|
||||
@@ -3435,17 +3435,18 @@ void manager_set_watchdog(Manager *m, WatchdogType t, usec_t timeout) {
|
||||
if (m->watchdog[t] == timeout)
|
||||
return;
|
||||
|
||||
if (t == WATCHDOG_RUNTIME) {
|
||||
if (!timestamp_is_set(m->watchdog_overridden[WATCHDOG_RUNTIME]))
|
||||
if (m->watchdog_overridden[t] == USEC_INFINITY) {
|
||||
if (t == WATCHDOG_RUNTIME)
|
||||
(void) watchdog_setup(timeout);
|
||||
} else if (t == WATCHDOG_PRETIMEOUT)
|
||||
if (m->watchdog_overridden[WATCHDOG_PRETIMEOUT] == USEC_INFINITY)
|
||||
else if (t == WATCHDOG_PRETIMEOUT)
|
||||
(void) watchdog_setup_pretimeout(timeout);
|
||||
}
|
||||
|
||||
m->watchdog[t] = timeout;
|
||||
}
|
||||
|
||||
void manager_override_watchdog(Manager *m, WatchdogType t, usec_t timeout) {
|
||||
usec_t usec;
|
||||
|
||||
assert(m);
|
||||
|
||||
@@ -3455,12 +3456,11 @@ void manager_override_watchdog(Manager *m, WatchdogType t, usec_t timeout) {
|
||||
if (m->watchdog_overridden[t] == timeout)
|
||||
return;
|
||||
|
||||
if (t == WATCHDOG_RUNTIME) {
|
||||
usec_t usec = timestamp_is_set(timeout) ? timeout : m->watchdog[t];
|
||||
|
||||
usec = (timeout == USEC_INFINITY) ? m->watchdog[t] : timeout;
|
||||
if (t == WATCHDOG_RUNTIME)
|
||||
(void) watchdog_setup(usec);
|
||||
} else if (t == WATCHDOG_PRETIMEOUT)
|
||||
(void) watchdog_setup_pretimeout(timeout);
|
||||
else if (t == WATCHDOG_PRETIMEOUT)
|
||||
(void) watchdog_setup_pretimeout(usec);
|
||||
|
||||
m->watchdog_overridden[t] = timeout;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user