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