aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2014-03-25 00:01:51 +0100
committerLennart Poettering <lennart@poettering.net>2014-03-25 00:01:51 +0100
commit75145780813957ecbe6835f2c8bc20113a3605d2 (patch)
tree7546f7d325ef760c64869e85c1824698c3c54b17
parentsd-event: initialization perturbation value right before we use it (diff)
downloadsystemd-75145780813957ecbe6835f2c8bc20113a3605d2.tar.gz
systemd-75145780813957ecbe6835f2c8bc20113a3605d2.tar.bz2
systemd-75145780813957ecbe6835f2c8bc20113a3605d2.zip
sd-event: don't accidentally turn of watchdog timer event if we determine 0
-rw-r--r--src/libsystemd/sd-event/sd-event.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c
index d6a3d1c3f..4aabec147 100644
--- a/src/libsystemd/sd-event/sd-event.c
+++ b/src/libsystemd/sd-event/sd-event.c
@@ -2087,6 +2087,11 @@ static int arm_watchdog(sd_event *e) {
timespec_store(&its.it_value, t);
+ /* Make sure we never set the watchdog to 0, which tells the
+ * kernel to disable it. */
+ if (its.it_value.tv_sec == 0 && its.it_value.tv_nsec == 0)
+ its.it_value.tv_nsec = 1;
+
r = timerfd_settime(e->watchdog_fd, TFD_TIMER_ABSTIME, &its, NULL);
if (r < 0)
return -errno;