chiark / gitweb /
udevd: event - make db loading lazy in REMOVE event handling
authorTom Gundersen <teg@jklm.no>
Fri, 6 Mar 2015 17:22:35 +0000 (18:22 +0100)
committerTom Gundersen <teg@jklm.no>
Thu, 12 Mar 2015 11:03:50 +0000 (12:03 +0100)
We were explicitly eagerly loading the db, then deletenig the backing file and then processing the
rules/symlinks. Instead we delete the backnig db file as the last step and let the db loading be
lazy as everywhere else.

This may save us a bit of work in casese where the db is not needed, but more importantly it hides
some implementation details of libudev-device form udevd.

src/libudev/libudev-device-private.c
src/udev/udev-event.c

index 15d3b23..e590288 100644 (file)
@@ -182,6 +182,7 @@ int udev_device_delete_db(struct udev_device *udev_device)
         if (id == NULL)
                 return -1;
         strscpyl(filename, sizeof(filename), "/run/udev/data/", id, NULL);
+
         unlink(filename);
         return 0;
 }
index b96cf73..4ca73d3 100644 (file)
@@ -793,10 +793,6 @@ void udev_event_execute_rules(struct udev_event *event,
                 return;
 
         if (streq(udev_device_get_action(dev), "remove")) {
-                udev_device_read_db(dev);
-                udev_device_delete_db(dev);
-                udev_device_tag_index(dev, NULL, false);
-
                 if (major(udev_device_get_devnum(dev)) != 0)
                         udev_watch_end(event->udev, dev);
 
@@ -807,6 +803,9 @@ void udev_event_execute_rules(struct udev_event *event,
 
                 if (major(udev_device_get_devnum(dev)) != 0)
                         udev_node_remove(dev);
+
+                udev_device_delete_db(dev);
+                udev_device_tag_index(dev, NULL, false);
         } else {
                 event->dev_db = udev_device_shallow_clone(dev);
                 if (event->dev_db != NULL) {