Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
varnish-cache
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
varnishcache
varnish-cache
Commits
e1e58370
Commit
e1e58370
authored
Apr 07, 2015
by
Martin Blix Grydeland
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement -t timeout option in VUT
parent
726b7926
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
76 additions
and
33 deletions
+76
-33
vut.h
include/vut.h
+2
-0
vut.c
lib/libvarnishtools/vut.c
+74
-33
No files found.
include/vut.h
View file @
e1e58370
...
...
@@ -40,6 +40,8 @@ struct VUT {
int
D_opt
;
int
g_arg
;
int
k_arg
;
char
*
n_arg
;
char
*
N_arg
;
char
*
P_arg
;
char
*
q_arg
;
char
*
r_arg
;
...
...
lib/libvarnishtools/vut.c
View file @
e1e58370
...
...
@@ -136,7 +136,6 @@ VUT_Arg(int opt, const char *arg)
{
int
i
;
char
*
p
;
double
d
;
switch
(
opt
)
{
case
'd'
:
...
...
@@ -157,21 +156,12 @@ VUT_Arg(int opt, const char *arg)
VUT_Error
(
1
,
"-k: Invalid number '%s'"
,
arg
);
return
(
1
);
case
'n'
:
/* Varnish instance */
if
(
VUT
.
vsm
==
NULL
)
VUT
.
vsm
=
VSM_New
();
AN
(
VUT
.
vsm
);
if
(
VSM_n_Arg
(
VUT
.
vsm
,
arg
)
<=
0
)
VUT_Error
(
1
,
"%s"
,
VSM_Error
(
VUT
.
vsm
));
/* Varnish instance name */
REPLACE
(
VUT
.
n_arg
,
arg
);
return
(
1
);
case
'N'
:
/* Varnish stale VSM file */
if
(
VUT
.
vsm
==
NULL
)
VUT
.
vsm
=
VSM_New
();
AN
(
VUT
.
vsm
);
if
(
VSM_N_Arg
(
VUT
.
vsm
,
arg
)
<=
0
)
VUT_Error
(
1
,
"%s"
,
VSM_Error
(
VUT
.
vsm
));
VUT
.
d_opt
=
1
;
/* Enforces -d */
REPLACE
(
VUT
.
N_arg
,
arg
);
return
(
1
);
case
'P'
:
/* PID file */
...
...
@@ -187,10 +177,15 @@ VUT_Arg(int opt, const char *arg)
return
(
1
);
case
't'
:
/* VSM connect timeout */
d
=
VNUM
(
arg
);
if
(
isnan
(
d
))
VUT_Error
(
1
,
"-t: Syntax error"
);
VUT
.
t_arg
=
d
;
if
(
!
strcasecmp
(
"off"
,
arg
))
VUT
.
t_arg
=
-
1
.;
else
{
VUT
.
t_arg
=
VNUM
(
arg
);
if
(
isnan
(
VUT
.
t_arg
))
VUT_Error
(
1
,
"-t: Syntax error"
);
if
(
VUT
.
t_arg
<
0
.)
VUT_Error
(
1
,
"-t: Range error"
);
}
return
(
1
);
case
'V'
:
/* Print version number and exit */
...
...
@@ -222,36 +217,80 @@ void
VUT_Setup
(
void
)
{
struct
VSL_cursor
*
c
;
double
t_start
;
int
i
;
AN
(
VUT
.
vsl
);
if
(
VUT
.
r_arg
&&
VUT
.
vsm
)
VUT_Error
(
1
,
"Can't have both -n and -r options"
);
AZ
(
VUT
.
vsm
);
AZ
(
VUT
.
vslq
);
/* Check input arguments */
if
((
VUT
.
n_arg
==
NULL
?
0
:
1
)
+
(
VUT
.
N_arg
==
NULL
?
0
:
1
)
+
(
VUT
.
r_arg
==
NULL
?
0
:
1
)
>
1
)
VUT_Error
(
1
,
"Only one of -n, -N and -r options may be used"
);
/* Create
query
*/
/* Create
and validate the query expression
*/
VUT
.
vslq
=
VSLQ_New
(
VUT
.
vsl
,
NULL
,
VUT
.
g_arg
,
VUT
.
q_arg
);
if
(
VUT
.
vslq
==
NULL
)
VUT_Error
(
1
,
"Query expression error:
\n
%s"
,
VSL_Error
(
VUT
.
vsl
));
/*
Input cursor
*/
/*
Setup input
*/
if
(
VUT
.
r_arg
)
{
REPLACE
(
VUT
.
name
,
VUT
.
r_arg
);
c
=
VSL_CursorFile
(
VUT
.
vsl
,
VUT
.
r_arg
,
0
);
if
(
c
==
NULL
)
VUT_Error
(
1
,
"Can't open log file (%s)"
,
VSL_Error
(
VUT
.
vsl
));
}
else
{
if
(
VUT
.
vsm
==
NULL
)
/* Default uses VSM with n=hostname */
VUT
.
vsm
=
VSM_New
();
VUT
.
vsm
=
VSM_New
();
AN
(
VUT
.
vsm
);
if
(
VSM_Open
(
VUT
.
vsm
))
VUT_Error
(
1
,
"Can't open VSM file (%s)"
,
VSM_Error
(
VUT
.
vsm
));
if
(
VUT
.
n_arg
&&
VSM_n_Arg
(
VUT
.
vsm
,
VUT
.
n_arg
)
<=
0
)
VUT_Error
(
1
,
"%s"
,
VSM_Error
(
VUT
.
vsm
));
if
(
VUT
.
N_arg
&&
VSM_N_Arg
(
VUT
.
vsm
,
VUT
.
N_arg
)
<=
0
)
VUT_Error
(
1
,
"%s"
,
VSM_Error
(
VUT
.
vsm
));
REPLACE
(
VUT
.
name
,
VSM_Name
(
VUT
.
vsm
));
c
=
VSL_CursorVSM
(
VUT
.
vsl
,
VUT
.
vsm
,
(
VUT
.
d_opt
?
VSL_COPT_TAILSTOP
:
VSL_COPT_TAIL
)
|
VSL_COPT_BATCH
);
t_start
=
NAN
;
c
=
NULL
;
while
(
1
)
{
i
=
VSM_Open
(
VUT
.
vsm
);
if
(
!
i
)
c
=
VSL_CursorVSM
(
VUT
.
vsl
,
VUT
.
vsm
,
(
VUT
.
d_opt
?
VSL_COPT_TAILSTOP
:
VSL_COPT_TAIL
)
|
VSL_COPT_BATCH
);
if
(
c
)
break
;
if
(
isnan
(
t_start
)
&&
VUT
.
t_arg
>
0
.)
{
VUT_Error
(
0
,
"Can't open log -"
" retrying for %.0f seconds"
,
VUT
.
t_arg
);
t_start
=
VTIM_real
();
}
VSM_Close
(
VUT
.
vsm
);
if
(
VUT
.
t_arg
<=
0
.)
break
;
if
(
VTIM_real
()
-
t_start
>
VUT
.
t_arg
)
break
;
VSM_ResetError
(
VUT
.
vsm
);
VSL_ResetError
(
VUT
.
vsl
);
VTIM_sleep
(
0
.
5
);
}
if
(
VUT
.
t_arg
>=
0
.
&&
(
i
||
!
c
))
{
if
(
i
)
VUT_Error
(
1
,
"Can't open VSM file (%s)"
,
VSM_Error
(
VUT
.
vsm
));
else
VUT_Error
(
1
,
"Can't open log (%s)"
,
VSL_Error
(
VUT
.
vsl
));
}
else
if
(
!
isnan
(
t_start
))
VUT_Error
(
0
,
"Log opened"
);
}
if
(
c
==
NULL
)
VUT_Error
(
1
,
"Can't open log (%s)"
,
VSL_Error
(
VUT
.
vsl
));
VSLQ_SetCursor
(
VUT
.
vslq
,
&
c
);
if
(
c
)
VSLQ_SetCursor
(
VUT
.
vslq
,
&
c
);
AZ
(
c
);
/* Signal handlers */
...
...
@@ -282,6 +321,8 @@ VUT_Setup(void)
void
VUT_Fini
(
void
)
{
free
(
VUT
.
n_arg
);
free
(
VUT
.
N_arg
);
free
(
VUT
.
r_arg
);
free
(
VUT
.
P_arg
);
free
(
VUT
.
name
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment