diff options
author | Lennart Poettering <lennart@poettering.net> | 2020-06-10 11:43:40 +0200 |
---|---|---|
committer | Daan De Meyer <daan.j.demeyer@gmail.com> | 2020-06-10 20:06:10 +0200 |
commit | 0f2d351f790516bc3f1158d964c5f83f339addb2 (patch) | |
tree | f9df08ab66c5c7be26c92e1767d39835cc9f472c /src/libudev | |
parent | 24bd74ae03efc98272236bd0a98a1d7d090d540c (diff) | |
download | systemd-0f2d351f790516bc3f1158d964c5f83f339addb2.tar.gz |
tree-wide: port to fd_wait_for_event()
Prompted by the discussion on #16110, let's migrate more code to
fd_wait_for_event().
This only leaves 7 places where we call into poll()/poll() directly in
our entire codebase. (one of which is fd_wait_for_event() itself)
Diffstat (limited to 'src/libudev')
-rw-r--r-- | src/libudev/libudev-monitor.c | 19 |
1 files changed, 6 insertions, 13 deletions
diff --git a/src/libudev/libudev-monitor.c b/src/libudev/libudev-monitor.c index bf23021b53..5bec7418b8 100644 --- a/src/libudev/libudev-monitor.c +++ b/src/libudev/libudev-monitor.c @@ -9,6 +9,7 @@ #include "device-monitor-private.h" #include "device-private.h" #include "device-util.h" +#include "io-util.h" #include "libudev-device-internal.h" #include "string-util.h" @@ -191,17 +192,11 @@ _public_ int udev_monitor_get_fd(struct udev_monitor *udev_monitor) { } static int udev_monitor_receive_sd_device(struct udev_monitor *udev_monitor, sd_device **ret) { - struct pollfd pfd; int r; assert(udev_monitor); assert(ret); - pfd = (struct pollfd) { - .fd = device_monitor_get_fd(udev_monitor->monitor), - .events = POLLIN, - }; - for (;;) { /* r == 0 means a device is received but it does not pass the current filter. */ r = device_monitor_receive_device(udev_monitor->monitor, ret); @@ -209,20 +204,18 @@ static int udev_monitor_receive_sd_device(struct udev_monitor *udev_monitor, sd_ return r; for (;;) { - /* wait next message */ - r = poll(&pfd, 1, 0); + /* Wait for next message */ + r = fd_wait_for_event(device_monitor_get_fd(udev_monitor->monitor), POLLIN, 0); if (r < 0) { - if (IN_SET(errno, EINTR, EAGAIN)) + if (IN_SET(r, -EINTR, -EAGAIN)) continue; - return -errno; + return r; } if (r == 0) return -EAGAIN; - if (pfd.revents & POLLNVAL) - return -EBADF; - /* receive next message */ + /* Receive next message */ break; } } |