chiark / gitweb /
core,logind,networkd: check for udev device initialization via enumeration matches
authorLennart Poettering <lennart@poettering.net>
Wed, 18 Dec 2013 16:12:15 +0000 (17:12 +0100)
committerLennart Poettering <lennart@poettering.net>
Wed, 18 Dec 2013 17:21:28 +0000 (18:21 +0100)
Instead of checking each device after we got it, check wuth an
enumeration filter instead, to make it more efficient.

src/core/device.c
src/login/logind-acl.c
src/login/logind.c
src/login/sysfs-show.c
src/network/networkd-manager.c

index c93c947..72d98ae 100644 (file)
@@ -303,14 +303,6 @@ static int device_process_new_device(Manager *m, struct udev_device *dev) {
 
         assert(m);
 
-#if 0
-        /* FIXME: this is always false for devices received from udev_monitor */
-
-        /* Don't pick up devices before udev finished initialization for them */
-        if (!udev_device_get_is_initialized(dev))
-                return 0;
-#endif
-
         sysfs = udev_device_get_syspath(dev);
         if (!sysfs)
                 return 0;
@@ -557,6 +549,10 @@ static int device_enumerate(Manager *m) {
         if (r < 0)
                 goto fail;
 
+        r = udev_enumerate_add_match_is_initialized(e);
+        if (r < 0)
+                goto fail;
+
         r = udev_enumerate_scan_devices(e);
         if (r < 0)
                 goto fail;
index 09a6f6d..dc86f0f 100644 (file)
@@ -210,6 +210,10 @@ int devnode_acl_all(struct udev *udev,
         if (r < 0)
                 return r;
 
+        r = udev_enumerate_add_match_is_initialized(e);
+        if (r < 0)
+                return r;
+
         r = udev_enumerate_scan_devices(e);
         if (r < 0)
                 return r;
@@ -223,9 +227,6 @@ int devnode_acl_all(struct udev *udev,
                 if (!d)
                         return -ENOMEM;
 
-                if (!udev_device_get_is_initialized(d))
-                        continue;
-
                 sn = udev_device_get_property_value(d, "ID_SEAT");
                 if (isempty(sn))
                         sn = "seat0";
index b97ba6d..48da7b1 100644 (file)
@@ -198,6 +198,10 @@ static int manager_enumerate_devices(Manager *m) {
         if (r < 0)
                 return r;
 
+        r = udev_enumerate_add_match_is_initialized(e);
+        if (r < 0)
+                return r;
+
         r = udev_enumerate_scan_devices(e);
         if (r < 0)
                 return r;
@@ -211,9 +215,6 @@ static int manager_enumerate_devices(Manager *m) {
                 if (!d)
                         return -ENOMEM;
 
-                if (!udev_device_get_is_initialized(d))
-                        continue;
-
                 k = manager_process_seat_device(m, d);
                 if (k < 0)
                         r = k;
@@ -249,6 +250,10 @@ static int manager_enumerate_buttons(Manager *m) {
         if (r < 0)
                 return r;
 
+        r = udev_enumerate_add_match_is_initialized(e);
+        if (r < 0)
+                return r;
+
         r = udev_enumerate_scan_devices(e);
         if (r < 0)
                 return r;
@@ -262,9 +267,6 @@ static int manager_enumerate_buttons(Manager *m) {
                 if (!d)
                         return -ENOMEM;
 
-                if (!udev_device_get_is_initialized(d))
-                        continue;
-
                 k = manager_process_button_device(m, d);
                 if (k < 0)
                         r = k;
index f7d11dd..05cb787 100644 (file)
@@ -170,7 +170,10 @@ int show_sysfs(const char *seat, const char *prefix, unsigned n_columns) {
                 r = udev_enumerate_add_match_tag(e, seat);
         else
                 r = udev_enumerate_add_match_tag(e, "seat");
+        if (r < 0)
+                return r;
 
+        r = udev_enumerate_add_match_is_initialized(e);
         if (r < 0)
                 return r;
 
index 6998562..c48c018 100644 (file)
@@ -171,6 +171,10 @@ int manager_udev_enumerate_links(Manager *m) {
         if (r < 0)
                 return r;
 
+        r = udev_enumerate_add_match_is_initialized(e);
+        if (r < 0)
+                return r;
+
         r = udev_enumerate_scan_devices(e);
         if (r < 0)
                 return r;
@@ -184,9 +188,6 @@ int manager_udev_enumerate_links(Manager *m) {
                 if (!d)
                         return -ENOMEM;
 
-                if (!udev_device_get_is_initialized(d))
-                        continue;
-
                 k = manager_process_link(m, d);
                 if (k < 0)
                         r = k;