]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
udevd: explicitly update queue file before answering to ping
authorTom Gundersen <teg@jklm.no>
Tue, 12 May 2015 14:55:29 +0000 (16:55 +0200)
committerTom Gundersen <teg@jklm.no>
Tue, 12 May 2015 15:06:21 +0000 (17:06 +0200)
This avoids updating the flag files twice for every loop, and also removes another dependency
in the main-loop, so we are freer to reshufle it as we want.

src/udev/udevd.c

index 8528f7147b535fffc99ea5ed28d90c3d6c7c88f6..e558098ef03f3bc4b1a913594fa501f2515f67e2 100644 (file)
@@ -696,6 +696,20 @@ static int on_uevent(sd_event_source *s, int fd, uint32_t revents, void *userdat
         return 1;
 }
 
+static void event_queue_update(void) {
+        int r;
+
+        if (!udev_list_node_is_empty(&event_list)) {
+                r = touch("/run/udev/queue");
+                if (r < 0)
+                        log_warning_errno(r, "could not touch /run/udev/queue: %m");
+        } else {
+                r = unlink("/run/udev/queue");
+                if (r < 0 && errno != ENOENT)
+                        log_warning("could not unlink /run/udev/queue: %m");
+        }
+}
+
 /* receive the udevd message from userspace */
 static int on_ctrl_msg(sd_event_source *s, int fd, uint32_t revents, void *userdata) {
         struct udev_ctrl *uctrl = userdata;
@@ -769,8 +783,13 @@ static int on_ctrl_msg(sd_event_source *s, int fd, uint32_t revents, void *userd
                 arg_children_max = i;
         }
 
-        if (udev_ctrl_get_ping(ctrl_msg) > 0)
+        if (udev_ctrl_get_ping(ctrl_msg) > 0) {
                 log_debug("udevd message (SYNC) received");
+                /* tell settle that we are busy or idle, this needs to be before the
+                 * PING handling
+                 */
+                event_queue_update();
+        }
 
         if (udev_ctrl_get_exit(ctrl_msg) > 0) {
                 log_debug("udevd message (EXIT) received");
@@ -987,20 +1006,6 @@ static int on_sigchld(sd_event_source *s, const struct signalfd_siginfo *si, voi
         return 1;
 }
 
-static void event_queue_update(void) {
-        int r;
-
-        if (!udev_list_node_is_empty(&event_list)) {
-                r = touch("/run/udev/queue");
-                if (r < 0)
-                        log_warning_errno(r, "could not touch /run/udev/queue: %m");
-        } else {
-                r = unlink("/run/udev/queue");
-                if (r < 0 && errno != ENOENT)
-                        log_warning("could not unlink /run/udev/queue: %m");
-        }
-}
-
 static int systemd_fds(struct udev *udev, int *rctrl, int *rnetlink) {
         int ctrl = -1, netlink = -1;
         int fd, n;
@@ -1575,11 +1580,6 @@ int main(int argc, char *argv[]) {
                 if (is_inotify)
                         on_inotify(NULL, fd_inotify, 0, udev);
 
-                /* tell settle that we are busy or idle, this needs to be before the
-                 * PING handling
-                 */
-                event_queue_update();
-
                 /*
                  * This needs to be after the inotify handling, to make sure,
                  * that the ping is send back after the possibly generated