[master] 7c3db3fe0 varnishadm: use the -t argument as the timeout
Nils Goroll
nils.goroll at uplex.de
Sat Apr 10 15:18:06 UTC 2021
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,
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.
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;
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();
More information about the varnish-commit
mailing list