summaryrefslogtreecommitdiffstats
path: root/src/libsystemd/sd-netlink
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2020-06-10 11:43:40 +0200
committerDaan De Meyer <daan.j.demeyer@gmail.com>2020-06-10 20:06:10 +0200
commit0f2d351f790516bc3f1158d964c5f83f339addb2 (patch)
treef9df08ab66c5c7be26c92e1767d39835cc9f472c /src/libsystemd/sd-netlink
parentMerge pull request #15940 from keszybz/names-set-optimization (diff)
downloadsystemd-0f2d351f790516bc3f1158d964c5f83f339addb2.tar.xz
systemd-0f2d351f790516bc3f1158d964c5f83f339addb2.zip
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/libsystemd/sd-netlink')
-rw-r--r--src/libsystemd/sd-netlink/sd-netlink.c16
1 files changed, 4 insertions, 12 deletions
diff --git a/src/libsystemd/sd-netlink/sd-netlink.c b/src/libsystemd/sd-netlink/sd-netlink.c
index ddeb4a7992..91670ee324 100644
--- a/src/libsystemd/sd-netlink/sd-netlink.c
+++ b/src/libsystemd/sd-netlink/sd-netlink.c
@@ -7,6 +7,7 @@
#include "alloc-util.h"
#include "fd-util.h"
#include "hashmap.h"
+#include "io-util.h"
#include "macro.h"
#include "netlink-internal.h"
#include "netlink-slot.h"
@@ -462,7 +463,6 @@ static usec_t calc_elapse(uint64_t usec) {
}
static int rtnl_poll(sd_netlink *rtnl, bool need_more, uint64_t timeout_usec) {
- struct timespec ts;
usec_t m = USEC_INFINITY;
int r, e;
@@ -491,23 +491,15 @@ static int rtnl_poll(sd_netlink *rtnl, bool need_more, uint64_t timeout_usec) {
}
}
- if (timeout_usec != (uint64_t) -1 && (m == (uint64_t) -1 || timeout_usec < m))
+ if (timeout_usec != (uint64_t) -1 && (m == USEC_INFINITY || timeout_usec < m))
m = timeout_usec;
- struct pollfd p = {
- .fd = rtnl->fd,
- .events = e,
- };
-
- r = ppoll(&p, 1, m == (uint64_t) -1 ? NULL : timespec_store(&ts, m), NULL);
+ r = fd_wait_for_event(rtnl->fd, e, m);
if (r < 0)
- return -errno;
+ return r;
if (r == 0)
return 0;
- if (p.revents & POLLNVAL)
- return -EBADF;
-
return 1;
}