ac3a84
From b546d82758e0149fd235d2ff8f9c4fdc8d0bd29c Mon Sep 17 00:00:00 2001
ac3a84
From: Lennart Poettering <lennart@poettering.net>
ac3a84
Date: Tue, 22 Nov 2022 12:55:10 +0100
ac3a84
Subject: [PATCH] homed: handle EINTR gracefully when waiting for device node
ac3a84
ac3a84
(cherry picked from commit f3d9278f38f0a9e03ed29215f27d8ca21c1fa6a1)
ac3a84
ac3a84
Related: #2137584
ac3a84
---
ac3a84
 src/home/homework-luks.c | 7 +++++--
ac3a84
 1 file changed, 5 insertions(+), 2 deletions(-)
ac3a84
ac3a84
diff --git a/src/home/homework-luks.c b/src/home/homework-luks.c
ac3a84
index 97fb5a1051..5e1d5bbd65 100644
ac3a84
--- a/src/home/homework-luks.c
ac3a84
+++ b/src/home/homework-luks.c
ac3a84
@@ -2017,9 +2017,12 @@ static int wait_for_devlink(const char *path) {
ac3a84
                 if (w >= until)
ac3a84
                         return log_error_errno(SYNTHETIC_ERRNO(ETIMEDOUT), "Device link %s still hasn't shown up, giving up.", path);
ac3a84
 
ac3a84
-                r = fd_wait_for_event(inotify_fd, POLLIN, usec_sub_unsigned(until, w));
ac3a84
-                if (r < 0)
ac3a84
+                r = fd_wait_for_event(inotify_fd, POLLIN, until - w);
ac3a84
+                if (r < 0) {
ac3a84
+                        if (ERRNO_IS_TRANSIENT(r))
ac3a84
+                                continue;
ac3a84
                         return log_error_errno(r, "Failed to watch inotify: %m");
ac3a84
+                }
ac3a84
 
ac3a84
                 (void) flush_fd(inotify_fd);
ac3a84
         }