From 9fb1cdb4808a65d1c96a99c1b0e53f54ba1b0d3b Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 24 Oct 2018 18:59:03 +0200 Subject: [PATCH] service: explicit stop the watchdog when we shall not use it This is useful so that WATCHDOG_USEC=0 sent from a process does the right thing if turning off the watchdog logic. --- src/core/service.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/core/service.c b/src/core/service.c index 510d8d6a3ad..93f0665bcf0 100644 --- a/src/core/service.c +++ b/src/core/service.c @@ -195,19 +195,21 @@ static usec_t service_get_watchdog_usec(Service *s) { if (s->watchdog_override_enable) return s->watchdog_override_usec; - else - return s->watchdog_usec; + + return s->watchdog_original_usec; } static void service_start_watchdog(Service *s) { - int r; usec_t watchdog_usec; + int r; assert(s); watchdog_usec = service_get_watchdog_usec(s); - if (IN_SET(watchdog_usec, 0, USEC_INFINITY)) + if (IN_SET(watchdog_usec, 0, USEC_INFINITY)) { + service_stop_watchdog(s); return; + } if (s->watchdog_event_source) { r = sd_event_source_set_time(s->watchdog_event_source, usec_add(s->watchdog_timestamp.monotonic, watchdog_usec));