summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2013-12-18 17:12:15 +0100
committerLennart Poettering <lennart@poettering.net>2013-12-18 18:21:28 +0100
commite120204729764f6243b60899eb907103e678bee2 (patch)
tree6513453989189dec5bdc57a2e0a28a2bfee2012a /src
parentfa28bc2df724e4aff46d19cb7aa732cc64c71061 (diff)
core,logind,networkd: check for udev device initialization via enumeration matches
Instead of checking each device after we got it, check wuth an enumeration filter instead, to make it more efficient.
Diffstat (limited to 'src')
-rw-r--r--src/core/device.c12
-rw-r--r--src/login/logind-acl.c7
-rw-r--r--src/login/logind.c14
-rw-r--r--src/login/sysfs-show.c3
-rw-r--r--src/network/networkd-manager.c7
5 files changed, 23 insertions, 20 deletions
diff --git a/src/core/device.c b/src/core/device.c
index c93c94726d..72d98aea72 100644
--- a/src/core/device.c
+++ b/src/core/device.c
@@ -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;
diff --git a/src/login/logind-acl.c b/src/login/logind-acl.c
index 09a6f6d90b..dc86f0f1a2 100644
--- a/src/login/logind-acl.c
+++ b/src/login/logind-acl.c
@@ -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";
diff --git a/src/login/logind.c b/src/login/logind.c
index b97ba6df3e..48da7b173b 100644
--- a/src/login/logind.c
+++ b/src/login/logind.c
@@ -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;
diff --git a/src/login/sysfs-show.c b/src/login/sysfs-show.c
index f7d11ddc4c..05cb787a68 100644
--- a/src/login/sysfs-show.c
+++ b/src/login/sysfs-show.c
@@ -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;
diff --git a/src/network/networkd-manager.c b/src/network/networkd-manager.c
index 6998562dc0..c48c0180ad 100644
--- a/src/network/networkd-manager.c
+++ b/src/network/networkd-manager.c
@@ -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;