]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udevadm-wait: move comments and condition outside of setup_periodic_timer()
authorYu Watanabe <watanabe.yu+github@gmail.com>
Wed, 31 Aug 2022 15:31:19 +0000 (00:31 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 2 Sep 2022 16:46:25 +0000 (01:46 +0900)
src/udev/udevadm-wait.c

index d9692ab86eee8a0a4ddc00a9860f6be406d41bd3..bebf9b6bae1fa035d01c6c8632c1dea760890c18 100644 (file)
@@ -286,20 +286,6 @@ static int setup_periodic_timer(sd_event *event) {
 
         assert(event);
 
-        /* If --initialized=no is specified, it is not necessary to wait uevents for the specified devices to
-         * be processed by udevd. Let's periodically check the devices. Then, we may be able to finish this
-         * program earlier when udevd is very busy.
-         *
-         * This is useful for working around issues #24360 and #24450.
-         * For some reasons, the kernel sometimes does not emit uevents for loop block device on attach.
-         * Hence, without the periodic timer, no event source for this program will be triggered, and this
-         * will be timed out.
-         * Theoretically, inotify watch may be better, but this program typically expected to run in a short
-         * time. Hence, let's use the simpler periodic timer event source here. */
-
-        if (arg_wait_until != WAIT_UNTIL_ADDED)
-                return 0;
-
         r = reset_timer(event, &s);
         if (r < 0)
                 return r;
@@ -428,9 +414,21 @@ int wait_main(int argc, char *argv[], void *userdata) {
         if (r < 0)
                 return log_error_errno(r, "Failed to set up device monitor: %m");
 
-        r = setup_periodic_timer(event);
-        if (r < 0)
-                return log_error_errno(r, "Failed to set up periodic timer: %m");
+        if (arg_wait_until == WAIT_UNTIL_ADDED) {
+                /* If --initialized=no is specified, it is not necessary to wait uevents for the specified
+                 * devices to be processed by udevd. Let's periodically check the devices. Then, we may be
+                 * able to finish this program earlier when udevd is very busy.
+                 *
+                 * This is useful for working around issues #24360 and #24450.
+                 * For some reasons, the kernel sometimes does not emit uevents for loop block device on
+                 * attach. Hence, without the periodic timer, no event source for this program will be
+                 * triggered, and this will be timed out.
+                 * Theoretically, inotify watch may be better, but this program typically expected to run in
+                 * a short time. Hence, let's use the simpler periodic timer event source here. */
+                r = setup_periodic_timer(event);
+                if (r < 0)
+                        return log_error_errno(r, "Failed to set up periodic timer: %m");
+        }
 
         /* Check before entering the event loop, as devices may be initialized during setting up event sources. */
         if (check())