diff options
author | Nir Soffer <nirsof@gmail.com> | 2015-04-08 04:04:16 +0300 |
---|---|---|
committer | Anthony G. Basile <blueness@gentoo.org> | 2015-04-12 13:18:06 -0400 |
commit | 1cd8de00b544c4f2ad97156c6c523209934bda9a (patch) | |
tree | db3aa071c2ac2992c7b5bc7b5d7df2a551fbdf15 /src/udev/udevadm-settle.c | |
parent | 24f869b793e7f4b565048441ed9bc9fde129e05b (diff) |
udev: restore udevadm settle timeout
Commit 9ea28c55a2 (udev: remove seqnum API and all assumptions about
seqnums) introduced a regresion, ignoring the timeout option when
waiting until the event queue is empty.
Previously, if the udev event queue was not empty when the timeout was
expired, udevadm settle was returning with exit code 1. To check if the
queue is empty, you could invoke udevadm settle with timeout=0. This
patch restores the previous behavior.
(David: fixed timeout==0 handling and dropped redundant assignment)
Signed-off-by: Anthony G. Basile <blueness@gentoo.org>
Diffstat (limited to 'src/udev/udevadm-settle.c')
-rw-r--r-- | src/udev/udevadm-settle.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/src/udev/udevadm-settle.c b/src/udev/udevadm-settle.c index fff5de7a8b..e60c4623bd 100644 --- a/src/udev/udevadm-settle.c +++ b/src/udev/udevadm-settle.c @@ -56,6 +56,7 @@ static int adm_settle(struct udev *udev, int argc, char *argv[]) { { "quiet", no_argument, NULL, 'q' }, /* removed */ {} }; + usec_t deadline; const char *exists = NULL; unsigned int timeout = 120; struct pollfd pfd[1] = { {.fd = -1}, }; @@ -105,6 +106,8 @@ static int adm_settle(struct udev *udev, int argc, char *argv[]) { return EXIT_FAILURE; } + deadline = now(CLOCK_MONOTONIC) + timeout * USEC_PER_SEC; + /* guarantee that the udev daemon isn't pre-processing */ if (getuid() == 0) { struct udev_ctrl *uctrl; @@ -146,6 +149,9 @@ static int adm_settle(struct udev *udev, int argc, char *argv[]) { break; } + if (timeout > 0 && now(CLOCK_MONOTONIC) >= deadline) + break; + /* wake up when queue is empty */ if (poll(pfd, 1, MSEC_PER_SEC) > 0 && pfd[0].revents & POLLIN) udev_queue_flush(queue); |