[master] 7c3db3fe0 varnishadm: use the -t argument as the timeout

Dridi Boukelmoune dridi at varni.sh
Mon Apr 12 08:15:27 UTC 2021


On Sat, Apr 10, 2021 at 3:18 PM Nils Goroll <nils.goroll at uplex.de> wrote:
>
>
> commit 7c3db3fe0fb594dcb22db12a8e16dbbf397e52a6
> Author: Nils Goroll <nils.goroll at uplex.de>
> Date:   Sat Apr 10 17:09:21 2021 +0200
>
>     varnishadm: use the -t argument as the timeout
>
>     We used the -t argument only for the VSM attach, not for the actual CLI
>     operations.
>
>     I do not think the complication of differentiated timeouts is justified,

Agreed.

>     so just use the one timeout parameter we have for both. Also I think
>     that the documentation is already adequate in its simplicity:
>
>            -t timeout
>                   Wait no longer than this many seconds for an operation to
>                   finish.

We should however make the default apparent.

>     Fixes #3542
>
> diff --git a/bin/varnishadm/varnishadm.c b/bin/varnishadm/varnishadm.c
> index 08c4a4125..ebc1aa2cc 100644
> --- a/bin/varnishadm/varnishadm.c
> +++ b/bin/varnishadm/varnishadm.c
> @@ -74,7 +74,7 @@
>         } while (0)
>
>
> -static const double timeout = 5;       // XXX should be settable by arg ?
> +static double timeout = 5;

Should we increase the default timeout to match varnishd´s default
cli_timeout instead of libvarnishapi´s t VSM argument?

>  static int p_arg = 0;
>
>  static void
> @@ -423,6 +423,21 @@ n_arg_sock(const char *n_arg, const char *t_arg)
>         return (sock);
>  }
>
> +static int
> +t_arg_timeout(const char *t_arg)
> +{
> +       char *p = NULL;
> +
> +       AN(t_arg);
> +       timeout = strtod(t_arg, &p);
> +       if ((p != NULL && *p != '\0') ||
> +           !isfinite(timeout) || timeout < 0) {
> +               fprintf(stderr, "-t: Invalid argument: %s", t_arg);
> +               return (-1);
> +       }
> +       return (1);
> +}
> +
>  #define OPTARG "hn:pS:T:t:"
>
>  int
> @@ -486,6 +501,9 @@ main(int argc, char * const *argv)
>         if (sock < 0)
>                 exit(2);
>
> +       if (t_arg != NULL && t_arg_timeout(t_arg) < 0)
> +               exit(2);
> +
>         if (argc > 0) {
>                 VSIG_Arm_int();
>                 VSIG_Arm_term();
> _______________________________________________
> varnish-commit mailing list
> varnish-commit at varnish-cache.org
> https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit


More information about the varnish-commit mailing list