[systemd-devel] [PATCH 3/6] udevd: explicitly try to start event queue when it may be possible

Tom Gundersen teg at jklm.no
Mon May 25 15:38:45 PDT 2015


Rather than trying to schedule new events on every main-loop iteration, do it explicitly when
processing an event finishes, a worker is killed, a new uevent is received, or the event queue
is explicitly restarted.
---
 src/udev/udevd.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/udev/udevd.c b/src/udev/udevd.c
index e309def..c9b0ed5 100644
--- a/src/udev/udevd.c
+++ b/src/udev/udevd.c
@@ -849,6 +849,9 @@ static int on_worker(sd_event_source *s, int fd, uint32_t revents, void *userdat
                 event_free(worker->event);
         }
 
+        /* we have free workers, try to schedule events */
+        event_queue_start(manager);
+
         return 1;
 }
 
@@ -865,6 +868,9 @@ static int on_uevent(sd_event_source *s, int fd, uint32_t revents, void *userdat
                 r = event_queue_insert(manager, dev);
                 if (r < 0)
                         udev_device_unref(dev);
+                else
+                        /* we have fresh events, try to schedule them */
+                        event_queue_start(manager);
         }
 
         return 1;
@@ -903,6 +909,7 @@ static int on_ctrl_msg(sd_event_source *s, int fd, uint32_t revents, void *userd
         if (udev_ctrl_get_start_exec_queue(ctrl_msg) > 0) {
                 log_debug("udevd message (START_EXEC_QUEUE) received");
                 manager->stop_exec_queue = false;
+                event_queue_start(manager);
         }
 
         if (udev_ctrl_get_reload(ctrl_msg) > 0) {
@@ -1169,6 +1176,9 @@ static int on_sigchld(sd_event_source *s, const struct signalfd_siginfo *si, voi
                 worker_free(worker);
         }
 
+        /* we can start new workers, try to schedule events */
+        event_queue_start(manager);
+
         return 1;
 }
 
@@ -1672,9 +1682,6 @@ int main(int argc, char *argv[]) {
                 if (is_uevent)
                         on_uevent(NULL, manager->fd_uevent, 0, manager);
 
-                /* start new events */
-                event_queue_start(manager);
-
                 if (is_signal) {
                         struct signalfd_siginfo fdsi;
                         ssize_t size;
-- 
2.3.4



More information about the systemd-devel mailing list