Blob Blame History Raw
From 32283b968af3c77eabed61a614e672f16e78cfb1 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Thu, 12 Feb 2015 12:28:48 +0100
Subject: [PATCH] core: disarm shutdown watchdog if we fail to set timeout

Better safe than sorry, if drivers are stupid, and reset immediately on
device closing if the timeout could not be initialized.

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=777735
(cherry picked from commit c2cc6b9aefb6f2085d3ca7eb9743093a17f751da)
---
 src/core/main.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/core/main.c b/src/core/main.c
index f0dd0c95b9..3c5bea4d57 100644
--- a/src/core/main.c
+++ b/src/core/main.c
@@ -2036,8 +2036,8 @@ finish:
                         /* If we reboot let's set the shutdown
                          * watchdog and tell the shutdown binary to
                          * repeatedly ping it */
-                        watchdog_set_timeout(&arg_shutdown_watchdog);
-                        watchdog_close(false);
+                        r = watchdog_set_timeout(&arg_shutdown_watchdog);
+                        watchdog_close(r < 0);
 
                         /* Tell the binary how often to ping, ignore failure */
                         if (asprintf(&e, "WATCHDOG_USEC="USEC_FMT, arg_shutdown_watchdog) > 0)