chiark / gitweb /
reap children faster
authorOlaf Kirch <okir@suse.de>
Wed, 21 Jan 2009 10:17:11 +0000 (11:17 +0100)
committerKay Sievers <kay.sievers@vrfy.org>
Wed, 21 Jan 2009 10:17:11 +0000 (11:17 +0100)
udevd's event_queue_manager loop is pretty sensitive to the
delays of exiting child processes. I found that it helps boot
times if we try to reap children as quickly as possible.

This patch changes event_queue_manager to call sigchilds_waiting
if it finds a signal has been received.

Signed-off-by: Olaf Kirch <okir@suse.de>
udev/udevd.c

index d227a71..9a278ce 100644 (file)
@@ -59,6 +59,8 @@ static void log_fn(struct udev *udev, int priority,
        }
 }
 
        }
 }
 
+static void reap_sigchilds(void);
+
 static int debug_trace;
 static struct udev_rules *rules;
 static struct udev_ctrl *udev_ctrl;
 static int debug_trace;
 static struct udev_rules *rules;
 static struct udev_ctrl *udev_ctrl;
@@ -403,6 +405,7 @@ static void event_queue_manager(struct udev *udev)
        struct udev_list_node *loop;
        struct udev_list_node *tmp;
 
        struct udev_list_node *loop;
        struct udev_list_node *tmp;
 
+start_over:
        if (udev_list_is_empty(&event_list)) {
                if (childs > 0) {
                        err(udev, "event list empty, but childs count is %i", childs);
        if (udev_list_is_empty(&event_list)) {
                if (childs > 0) {
                        err(udev, "event list empty, but childs count is %i", childs);
@@ -432,6 +435,13 @@ static void event_queue_manager(struct udev *udev)
 
                event_fork(loop_event);
                dbg(udev, "moved seq %llu to running list\n", udev_device_get_seqnum(loop_event->dev));
 
                event_fork(loop_event);
                dbg(udev, "moved seq %llu to running list\n", udev_device_get_seqnum(loop_event->dev));
+
+               /* retry if events finished in the meantime */
+               if (sigchilds_waiting) {
+                       sigchilds_waiting = 0;
+                       reap_sigchilds();
+                       goto start_over;
+               }
        }
 }
 
        }
 }