daandemeyer / rpms / systemd

Forked from rpms/systemd 2 years ago
Clone
803fb7
From b2575f7d4f06ab9df5c5744e0324160effda437e Mon Sep 17 00:00:00 2001
803fb7
From: Nir Soffer <nirsof@gmail.com>
803fb7
Date: Wed, 8 Apr 2015 04:04:16 +0300
803fb7
Subject: [PATCH] udev: restore udevadm settle timeout
803fb7
803fb7
Commit 9ea28c55a2 (udev: remove seqnum API and all assumptions about
803fb7
seqnums) introduced a regresion, ignoring the timeout option when
803fb7
waiting until the event queue is empty.
803fb7
803fb7
Previously, if the udev event queue was not empty when the timeout was
803fb7
expired, udevadm settle was returning with exit code 1.  To check if the
803fb7
queue is empty, you could invoke udevadm settle with timeout=0. This
803fb7
patch restores the previous behavior.
803fb7
803fb7
(David: fixed timeout==0 handling and dropped redundant assignment)
803fb7
803fb7
Cherry-picked from: 0736455b1186c9515e0f093e1e686e684d225787
803fb7
Resolves: #1210981
803fb7
---
803fb7
 src/udev/udevadm-settle.c | 6 ++++++
803fb7
 1 file changed, 6 insertions(+)
803fb7
803fb7
diff --git a/src/udev/udevadm-settle.c b/src/udev/udevadm-settle.c
803fb7
index fff5de7a8..e60c4623b 100644
803fb7
--- a/src/udev/udevadm-settle.c
803fb7
+++ b/src/udev/udevadm-settle.c
803fb7
@@ -56,6 +56,7 @@ static int adm_settle(struct udev *udev, int argc, char *argv[]) {
803fb7
                 { "quiet",          no_argument,       NULL, 'q' }, /* removed */
803fb7
                 {}
803fb7
         };
803fb7
+        usec_t deadline;
803fb7
         const char *exists = NULL;
803fb7
         unsigned int timeout = 120;
803fb7
         struct pollfd pfd[1] = { {.fd = -1}, };
803fb7
@@ -105,6 +106,8 @@ static int adm_settle(struct udev *udev, int argc, char *argv[]) {
803fb7
                 return EXIT_FAILURE;
803fb7
         }
803fb7
 
803fb7
+        deadline = now(CLOCK_MONOTONIC) + timeout * USEC_PER_SEC;
803fb7
+
803fb7
         /* guarantee that the udev daemon isn't pre-processing */
803fb7
         if (getuid() == 0) {
803fb7
                 struct udev_ctrl *uctrl;
803fb7
@@ -146,6 +149,9 @@ static int adm_settle(struct udev *udev, int argc, char *argv[]) {
803fb7
                         break;
803fb7
                 }
803fb7
 
803fb7
+                if (timeout > 0 && now(CLOCK_MONOTONIC) >= deadline)
803fb7
+                        break;
803fb7
+
803fb7
                 /* wake up when queue is empty */
803fb7
                 if (poll(pfd, 1, MSEC_PER_SEC) > 0 && pfd[0].revents & POLLIN)
803fb7
                         udev_queue_flush(queue);