anitazha / rpms / systemd

Forked from rpms/systemd 3 years ago
Clone

Blame SOURCES/0138-udev-restore-udevadm-settle-timeout.patch

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