Commit 726b7926 authored by Martin Blix Grydeland's avatar Martin Blix Grydeland

Add -t VSM open timeout option

This option controls the timeout for the initial VSM open operation
parent 3bfcf8b3
...@@ -43,6 +43,7 @@ struct VUT { ...@@ -43,6 +43,7 @@ struct VUT {
char *P_arg; char *P_arg;
char *q_arg; char *q_arg;
char *r_arg; char *r_arg;
double t_arg;
/* State */ /* State */
struct VSL_data *vsl; struct VSL_data *vsl;
......
...@@ -84,6 +84,18 @@ ...@@ -84,6 +84,18 @@
"Read log in binary file format from this file." \ "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 \ #define VUT_OPT_V \
VOPT("V", "[-V]", "Version", \ VOPT("V", "[-V]", "Version", \
"Print version information and exit." \ "Print version information and exit." \
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include <errno.h> #include <errno.h>
#include <string.h> #include <string.h>
#include <signal.h> #include <signal.h>
#include <math.h>
#include "compat/daemon.h" #include "compat/daemon.h"
#include "vdef.h" #include "vdef.h"
...@@ -49,6 +50,7 @@ ...@@ -49,6 +50,7 @@
#include "vas.h" #include "vas.h"
#include "miniobj.h" #include "miniobj.h"
#include "vcs.h" #include "vcs.h"
#include "vnum.h"
#include "vut.h" #include "vut.h"
...@@ -134,6 +136,7 @@ VUT_Arg(int opt, const char *arg) ...@@ -134,6 +136,7 @@ VUT_Arg(int opt, const char *arg)
{ {
int i; int i;
char *p; char *p;
double d;
switch (opt) { switch (opt) {
case 'd': case 'd':
...@@ -182,6 +185,13 @@ VUT_Arg(int opt, const char *arg) ...@@ -182,6 +185,13 @@ VUT_Arg(int opt, const char *arg)
/* Binary file input */ /* Binary file input */
REPLACE(VUT.r_arg, arg); REPLACE(VUT.r_arg, arg);
return (1); 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': case 'V':
/* Print version number and exit */ /* Print version number and exit */
VCS_Message(VUT.progname); VCS_Message(VUT.progname);
...@@ -205,6 +215,7 @@ VUT_Init(const char *progname) ...@@ -205,6 +215,7 @@ VUT_Init(const char *progname)
VUT.vsl = VSL_New(); VUT.vsl = VSL_New();
AN(VUT.vsl); AN(VUT.vsl);
VUT.k_arg = -1; VUT.k_arg = -1;
VUT.t_arg = 5.;
} }
void void
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment