]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
watchdog: update watchdog_timeout with the closest timeout found by the driver
authorFranck Bui <fbui@suse.com>
Mon, 6 Sep 2021 10:12:45 +0000 (12:12 +0200)
committerFranck Bui <fbui@suse.com>
Wed, 15 Sep 2021 09:32:10 +0000 (11:32 +0200)
Store the actual timeout value found by the driver in watchdog_timeout since
this value is more accurate for calculating the next time for pinging the
device.

src/shared/watchdog.c

index c57dafbca54bc7a9182ee309e20b3cbbf58d19be..c49972c8296afb764f1f4c5042462e1cfe31bf5c 100644 (file)
@@ -40,7 +40,12 @@ static int update_timeout(void) {
                 if (ioctl(watchdog_fd, WDIOC_SETTIMEOUT, &sec) < 0)
                         return log_warning_errno(errno, "Failed to set timeout to %is: %m", sec);
 
-                log_info("Set hardware watchdog to %s.", FORMAT_TIMESPAN(sec * USEC_PER_SEC, 0));
+                /* Just in case the driver is buggy */
+                assert(sec > 0);
+
+                /* watchdog_timeout stores the actual timeout used by the HW */
+                watchdog_timeout = sec * USEC_PER_SEC;
+                log_info("Set hardware watchdog to %s.", FORMAT_TIMESPAN(watchdog_timeout, 0));
 
                 flags = WDIOS_ENABLECARD;
                 if (ioctl(watchdog_fd, WDIOC_SETOPTIONS, &flags) < 0) {