From e120204729764f6243b60899eb907103e678bee2 Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 18 Dec 2013 17:12:15 +0100 Subject: 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. --- src/login/logind-acl.c | 7 ++++--- src/login/logind.c | 14 ++++++++------ src/login/sysfs-show.c | 3 +++ 3 files changed, 15 insertions(+), 9 deletions(-) (limited to 'src/login') 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; -- cgit v1.2.1