1
0
mirror of https://github.com/systemd/systemd.git synced 2025-03-19 22:50:17 +03:00

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.
This commit is contained in:
S. Fan 2017-07-31 05:10:10 -05:00 committed by Lennart Poettering
parent 0864d31176
commit 8ec1a07998

View File

@ -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;
}