[systemd-devel] [PATCH] udev: Restore udevadm settle timeout

David Herrmann dh.herrmann at gmail.com
Sat Apr 11 03:36:42 PDT 2015


Hi

On Wed, Apr 8, 2015 at 3:04 AM, Nir Soffer <nirsof at gmail.com> wrote:
> 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.
> ---
>  src/udev/udevadm-settle.c | 6 ++++++
>  1 file changed, 6 insertions(+)
>
> diff --git a/src/udev/udevadm-settle.c b/src/udev/udevadm-settle.c
> index 0d3025e..715d2e7 100644
> --- a/src/udev/udevadm-settle.c
> +++ b/src/udev/udevadm-settle.c
> @@ -49,6 +49,7 @@ static int adm_settle(struct udev *udev, int argc, char *argv[]) {
>                  { "quiet",          no_argument,       NULL, 'q' }, /* removed */
>                  {}
>          };
> +        usec_t deadline = 0;

This assignment is not required, dropped.

>          const char *exists = NULL;
>          unsigned int timeout = 120;
>          struct pollfd pfd[1] = { {.fd = -1}, };
> @@ -98,6 +99,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;
> @@ -139,6 +142,9 @@ static int adm_settle(struct udev *udev, int argc, char *argv[]) {
>                          break;
>                  }
>
> +                if (now(CLOCK_MONOTONIC) >= deadline)
> +                        break;
> +

Previous udevadm allowed timeout=0 to disable this. I added the condition.

Applied!

Thanks
David

>                  /* wake up when queue is empty */
>                  if (poll(pfd, 1, MSEC_PER_SEC) > 0 && pfd[0].revents & POLLIN)
>                          udev_queue_flush(queue);
> --
> 1.9.3
>
> _______________________________________________
> systemd-devel mailing list
> systemd-devel at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/systemd-devel


More information about the systemd-devel mailing list