|
|
2aacef |
From cd822ff6ef904e3e25060e77556670784b0b1aea Mon Sep 17 00:00:00 2001
|
|
|
2aacef |
From: Lennart Poettering <lennart@poettering.net>
|
|
|
2aacef |
Date: Tue, 22 Nov 2022 13:00:48 +0100
|
|
|
2aacef |
Subject: [PATCH] sd-netlink: handle EINTR from poll() gracefully, as success
|
|
|
2aacef |
|
|
|
2aacef |
(cherry picked from commit 69858785335afffc51bc03127beb53332c0fb983)
|
|
|
2aacef |
|
|
|
2aacef |
Related: #2137584
|
|
|
2aacef |
---
|
|
|
2aacef |
src/libsystemd/sd-netlink/sd-netlink.c | 7 ++++++-
|
|
|
2aacef |
1 file changed, 6 insertions(+), 1 deletion(-)
|
|
|
2aacef |
|
|
|
2aacef |
diff --git a/src/libsystemd/sd-netlink/sd-netlink.c b/src/libsystemd/sd-netlink/sd-netlink.c
|
|
|
2aacef |
index feb751a848..b99abae640 100644
|
|
|
2aacef |
--- a/src/libsystemd/sd-netlink/sd-netlink.c
|
|
|
2aacef |
+++ b/src/libsystemd/sd-netlink/sd-netlink.c
|
|
|
2aacef |
@@ -464,13 +464,18 @@ static int netlink_poll(sd_netlink *nl, bool need_more, usec_t timeout_usec) {
|
|
|
2aacef |
}
|
|
|
2aacef |
|
|
|
2aacef |
int sd_netlink_wait(sd_netlink *nl, uint64_t timeout_usec) {
|
|
|
2aacef |
+ int r;
|
|
|
2aacef |
+
|
|
|
2aacef |
assert_return(nl, -EINVAL);
|
|
|
2aacef |
assert_return(!netlink_pid_changed(nl), -ECHILD);
|
|
|
2aacef |
|
|
|
2aacef |
if (nl->rqueue_size > 0)
|
|
|
2aacef |
return 0;
|
|
|
2aacef |
|
|
|
2aacef |
- return netlink_poll(nl, false, timeout_usec);
|
|
|
2aacef |
+ r = netlink_poll(nl, false, timeout_usec);
|
|
|
2aacef |
+ if (r < 0 && ERRNO_IS_TRANSIENT(r)) /* Convert EINTR to "something happened" and give user a chance to run some code before calling back into us */
|
|
|
2aacef |
+ return 1;
|
|
|
2aacef |
+ return r;
|
|
|
2aacef |
}
|
|
|
2aacef |
|
|
|
2aacef |
static int timeout_compare(const void *a, const void *b) {
|