chiark / gitweb /
udevd: always try to find an idle worker instead of forking a new one
[elogind.git] / udev / udevd.c
index 170225d00c85457f2fbdb735fb08e405c847190d..7712543734aba9bf86d04f79e911683538500686 100644 (file)
@@ -168,7 +168,7 @@ static void event_queue_delete(struct event *event)
        udev_list_node_remove(&event->node);
 
        /* mark as failed, if "add" event returns non-zero */
-       if (event->exitcode != 0 && strcmp(udev_device_get_action(event->dev), "add") == 0)
+       if (event->exitcode != 0 && strcmp(udev_device_get_action(event->dev), "remove") != 0)
                udev_queue_export_device_failed(udev_queue_export, event->dev);
        else
                udev_queue_export_device_finished(udev_queue_export, event->dev);
@@ -360,7 +360,7 @@ static void worker_new(struct event *event)
        }
 }
 
-static void event_run(struct event *event)
+static void event_run(struct event *event, bool force)
 {
        struct udev_list_node *loop;
 
@@ -385,7 +385,7 @@ static void event_run(struct event *event)
                return;
        }
 
-       if (childs >= max_childs) {
+       if (!force && childs >= max_childs) {
                info(event->udev, "maximum number (%i) of childs reached\n", childs);
                return;
        }
@@ -420,7 +420,7 @@ static void event_queue_insert(struct udev_device *dev)
 
        /* run all events with a timeout set immediately */
        if (udev_device_get_timeout(dev) > 0) {
-               worker_new(event);
+               event_run(event, true);
                return;
        }
 }
@@ -552,7 +552,7 @@ static void events_start(struct udev *udev)
                        continue;
                }
 
-               event_run(event);
+               event_run(event, false);
        }
 }
 
@@ -887,15 +887,15 @@ int main(int argc, char *argv[])
 
        if (udev_get_rules_path(udev) != NULL) {
                inotify_add_watch(pfd[FD_INOTIFY].fd, udev_get_rules_path(udev),
-                                 IN_CREATE | IN_DELETE | IN_MOVE | IN_CLOSE_WRITE);
+                                 IN_DELETE | IN_MOVE | IN_CLOSE_WRITE);
        } else {
                char filename[UTIL_PATH_SIZE];
                struct stat statbuf;
 
                inotify_add_watch(pfd[FD_INOTIFY].fd, LIBEXECDIR "/rules.d",
-                                 IN_CREATE | IN_DELETE | IN_MOVE | IN_CLOSE_WRITE);
+                                 IN_DELETE | IN_MOVE | IN_CLOSE_WRITE);
                inotify_add_watch(pfd[FD_INOTIFY].fd, SYSCONFDIR "/udev/rules.d",
-                                 IN_CREATE | IN_DELETE | IN_MOVE | IN_CLOSE_WRITE);
+                                 IN_DELETE | IN_MOVE | IN_CLOSE_WRITE);
 
                /* watch dynamic rules directory */
                util_strscpyl(filename, sizeof(filename), udev_get_dev_path(udev), "/.udev/rules.d", NULL);
@@ -906,7 +906,7 @@ int main(int argc, char *argv[])
                        udev_selinux_resetfscreatecon(udev);
                }
                inotify_add_watch(pfd[FD_INOTIFY].fd, filename,
-                                 IN_CREATE | IN_DELETE | IN_MOVE | IN_CLOSE_WRITE);
+                                 IN_DELETE | IN_MOVE | IN_CLOSE_WRITE);
        }
        udev_watch_restore(udev);