]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
watchdog: minor optimization in watchdog_setup()
authorFranck Bui <fbui@suse.com>
Fri, 17 Sep 2021 07:21:18 +0000 (09:21 +0200)
committerFranck Bui <fbui@suse.com>
Wed, 13 Oct 2021 06:50:08 +0000 (08:50 +0200)
src/shared/watchdog.c

index 78c13a7b059be002ac630957beae912382010bb8..3f4effddb51c9d2807848c4c99e66af1dd735c2c 100644 (file)
@@ -134,6 +134,10 @@ int watchdog_set_device(const char *path) {
 
 int watchdog_setup(usec_t timeout) {
 
+        /* Let's shortcut duplicated requests */
+        if (watchdog_fd >= 0 && watchdog_timeout == timeout)
+                return 0;
+
         /* Initialize the watchdog timeout with the caller value. This value is
          * going to be updated by update_timeout() with the closest value
          * supported by the driver */