summaryrefslogtreecommitdiff
path: root/src/rfkill
diff options
context:
space:
mode:
authorS. Fan <sfanxiang@gmail.com>2017-07-31 05:10:10 -0500
committerLennart Poettering <lennart@poettering.net>2017-07-31 12:10:10 +0200
commit8ec1a07998758f6a85f3ea5bf2ed14d87609398f (patch)
tree1866bc7ae68b0cceecef40983f16a97b982b00dd /src/rfkill
parent0864d311766498563331f486909a0d950ba7de87 (diff)
downloadsystemd-8ec1a07998758f6a85f3ea5bf2ed14d87609398f.tar.gz
rfkill: fix erroneous behavior when polling the udev monitor (#6489)
Comparing udev_device_get_sysname(device) and sysname will always return true. We need to check the device received from udev monitor instead. Also, fd_wait_for_event() sometimes never exits. Better set a timeout here.
Diffstat (limited to 'src/rfkill')
-rw-r--r--src/rfkill/rfkill.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/rfkill/rfkill.c b/src/rfkill/rfkill.c
index c0f138b4f4..470853d1d2 100644
--- a/src/rfkill/rfkill.c
+++ b/src/rfkill/rfkill.c
@@ -138,17 +138,21 @@ static int wait_for_initialized(
for (;;) {
_cleanup_udev_device_unref_ struct udev_device *t = NULL;
- r = fd_wait_for_event(watch_fd, POLLIN, USEC_INFINITY);
+ r = fd_wait_for_event(watch_fd, POLLIN, EXIT_USEC);
if (r == -EINTR)
continue;
if (r < 0)
return log_error_errno(r, "Failed to watch udev monitor: %m");
+ if (r == 0) {
+ log_error("Timed out wating for udev monitor.");
+ return -ETIMEDOUT;
+ }
t = udev_monitor_receive_device(monitor);
if (!t)
continue;
- if (streq_ptr(udev_device_get_sysname(device), sysname)) {
+ if (streq_ptr(udev_device_get_sysname(t), sysname)) {
*ret = udev_device_ref(t);
return 0;
}