systemd/SOURCES/0132-varlink-also-handle-EINTR-gracefully-when-waiting-fo.patch
2023-03-29 11:21:50 +00:00

51 lines
1.9 KiB
Diff

From e95dd8e99188377bb6351fc0a4ceb4e790612044 Mon Sep 17 00:00:00 2001
From: Lennart Poettering <lennart@poettering.net>
Date: Tue, 22 Nov 2022 12:42:46 +0100
Subject: [PATCH] varlink: also handle EINTR gracefully when waiting for EIO
via ppoll()
(cherry picked from commit 6976bf5cd614761eb4bd57d39e24f7eca1d6b863)
Related: #2137584
---
src/shared/varlink.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)
diff --git a/src/shared/varlink.c b/src/shared/varlink.c
index 4f7ac97689..4d2cfee491 100644
--- a/src/shared/varlink.c
+++ b/src/shared/varlink.c
@@ -1025,7 +1025,7 @@ static void handle_revents(Varlink *v, int revents) {
if ((revents & (POLLOUT|POLLHUP)) == 0)
return;
- varlink_log(v, "Anynchronous connection completed.");
+ varlink_log(v, "Asynchronous connection completed.");
v->connecting = false;
} else {
/* Note that we don't care much about POLLIN/POLLOUT here, we'll just try reading and writing
@@ -1075,6 +1075,9 @@ int varlink_wait(Varlink *v, usec_t timeout) {
return events;
r = fd_wait_for_event(fd, events, t);
+ if (r < 0 && ERRNO_IS_TRANSIENT(r)) /* Treat EINTR as not a timeout, but also nothing happened, and
+ * the caller gets a chance to call back into us */
+ return 1;
if (r <= 0)
return r;
@@ -1161,8 +1164,12 @@ int varlink_flush(Varlink *v) {
}
r = fd_wait_for_event(v->fd, POLLOUT, USEC_INFINITY);
- if (r < 0)
+ if (r < 0) {
+ if (ERRNO_IS_TRANSIENT(r))
+ continue;
+
return varlink_log_errno(v, r, "Poll failed on fd: %m");
+ }
assert(r != 0);