[master] 726b792 Add -t VSM open timeout option

Martin Blix Grydeland martin at varnish-software.com
Thu Apr 9 15:16:28 CEST 2015


commit 726b7926c9feb2e499720195597abf168e412330
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date:   Tue Mar 31 15:03:33 2015 +0200

    Add -t VSM open timeout option
    
    This option controls the timeout for the initial VSM open operation

diff --git a/include/vut.h b/include/vut.h
index 6558227..8c0a55f 100644
--- a/include/vut.h
+++ b/include/vut.h
@@ -43,6 +43,7 @@ struct VUT {
 	char		*P_arg;
 	char		*q_arg;
 	char		*r_arg;
+	double		t_arg;
 
 	/* State */
 	struct VSL_data	*vsl;
diff --git a/include/vut_options.h b/include/vut_options.h
index 9f01181..6004690 100644
--- a/include/vut_options.h
+++ b/include/vut_options.h
@@ -84,6 +84,18 @@
 	    "Read log in binary file format from this file."		\
 	)
 
+#define VUT_OPT_t							\
+	VOPT("t:", "[-t seconds|<off>]", "VSM connection timeout",	\
+	    "Timeout before returning error on initial VSM connection."	\
+	    " If set the VSM connection is retried every 0.5 seconds"	\
+	    " for this many seconds. If zero the connection is"		\
+	    " attempted only once and will fail immediately if"		\
+	    " unsuccessful. If set to \"off\", the connection will not"	\
+	    " fail, allowing the utility to start and wait"		\
+	    " indefinetely for the Varnish instance to appear. "	\
+	    " Defaults to 5 seconds."					\
+	)
+
 #define VUT_OPT_V							\
 	VOPT("V", "[-V]", "Version",					\
 	    "Print version information and exit."			\
diff --git a/lib/libvarnishtools/vut.c b/lib/libvarnishtools/vut.c
index 0e8b657..03917b4 100644
--- a/lib/libvarnishtools/vut.c
+++ b/lib/libvarnishtools/vut.c
@@ -39,6 +39,7 @@
 #include <errno.h>
 #include <string.h>
 #include <signal.h>
+#include <math.h>
 
 #include "compat/daemon.h"
 #include "vdef.h"
@@ -49,6 +50,7 @@
 #include "vas.h"
 #include "miniobj.h"
 #include "vcs.h"
+#include "vnum.h"
 
 #include "vut.h"
 
@@ -134,6 +136,7 @@ VUT_Arg(int opt, const char *arg)
 {
 	int i;
 	char *p;
+	double d;
 
 	switch (opt) {
 	case 'd':
@@ -182,6 +185,13 @@ VUT_Arg(int opt, const char *arg)
 		/* Binary file input */
 		REPLACE(VUT.r_arg, arg);
 		return (1);
+	case 't':
+		/* VSM connect timeout */
+		d = VNUM(arg);
+		if (isnan(d))
+			VUT_Error(1, "-t: Syntax error");
+		VUT.t_arg = d;
+		return (1);
 	case 'V':
 		/* Print version number and exit */
 		VCS_Message(VUT.progname);
@@ -205,6 +215,7 @@ VUT_Init(const char *progname)
 	VUT.vsl = VSL_New();
 	AN(VUT.vsl);
 	VUT.k_arg = -1;
+	VUT.t_arg = 5.;
 }
 
 void



More information about the varnish-commit mailing list