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
ec1e6f40
Commit
ec1e6f40
authored
Jun 28, 2017
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Introduce VSM_Start() which takes care of waiting around for varnishd
if that is desired.
parent
469d65e0
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
83 additions
and
95 deletions
+83
-95
varnishadm.c
bin/varnishadm/varnishadm.c
+1
-1
varnishstat.c
bin/varnishstat/varnishstat.c
+5
-27
u00005.vtc
bin/varnishtest/tests/u00005.vtc
+1
-1
vtc_logexp.c
bin/varnishtest/vtc_logexp.c
+28
-27
vtc_varnish.c
bin/varnishtest/vtc_varnish.c
+3
-0
vsm.h
include/vapi/vsm.h
+2
-0
libvarnishapi.map
lib/libvarnishapi/libvarnishapi.map
+1
-0
vsm.c
lib/libvarnishapi/vsm.c
+34
-0
vut.c
lib/libvarnishapi/vut.c
+8
-39
No files found.
bin/varnishadm/varnishadm.c
View file @
ec1e6f40
...
...
@@ -405,7 +405,7 @@ n_arg_sock(const char *n_arg)
VSM_Destroy
(
&
vsm
);
return
(
-
1
);
}
if
(
VSM_
Open
(
vsm
))
{
if
(
VSM_
Start
(
vsm
,
0
,
-
1
))
{
fprintf
(
stderr
,
"%s
\n
"
,
VSM_Error
(
vsm
));
VSM_Destroy
(
&
vsm
);
return
(
-
1
);
...
...
bin/varnishstat/varnishstat.c
View file @
ec1e6f40
...
...
@@ -253,7 +253,7 @@ int
main
(
int
argc
,
char
*
const
*
argv
)
{
struct
vsm
*
vd
;
double
t_arg
=
5
.
0
,
t_start
=
NAN
;
double
t_arg
=
5
.
0
;
int
once
=
0
,
xml
=
0
,
json
=
0
,
f_list
=
0
,
curses
=
0
;
signed
char
opt
;
int
i
;
...
...
@@ -308,34 +308,12 @@ main(int argc, char * const *argv)
if
(
!
(
xml
||
json
||
once
||
f_list
))
curses
=
1
;
while
(
1
)
{
i
=
VSM_Open
(
vd
);
if
(
!
i
)
break
;
if
(
isnan
(
t_start
)
&&
t_arg
>
0
.)
{
fprintf
(
stderr
,
"Can't open log -"
" retrying for %.0f seconds
\n
"
,
t_arg
);
t_start
=
VTIM_real
();
}
if
(
t_arg
<=
0
.)
break
;
if
(
VTIM_real
()
-
t_start
>
t_arg
)
break
;
VSM_ResetError
(
vd
);
VTIM_sleep
(
0
.
5
);
}
if
(
curses
)
{
if
(
i
&&
t_arg
>=
0
.)
VUT_Error
(
1
,
"%s"
,
VSM_Error
(
vd
));
do_curses
(
vd
,
1
.
0
);
exit
(
0
);
}
if
(
i
)
if
(
VSM_Start
(
vd
,
t_arg
,
STDERR_FILENO
))
VUT_Error
(
1
,
"%s"
,
VSM_Error
(
vd
));
if
(
xml
)
if
(
curses
)
do_curses
(
vd
,
1
.
0
);
else
if
(
xml
)
do_xml
(
vd
);
else
if
(
json
)
do_json
(
vd
);
...
...
bin/varnishtest/tests/u00005.vtc
View file @
ec1e6f40
...
...
@@ -41,7 +41,7 @@ shell -err -expect "-t: Range error" \
"varnishstat -t -1"
shell -err -expect "-t: Syntax error" \
"varnishstat -t foo"
shell -err -expect "C
annot open /nonexistent/_.vsm
" \
shell -err -expect "C
ould not get hold of varnishd
" \
"varnishstat -n /nonexistent -t 1"
shell -expect "MAIN.uptime" \
"varnishstat -n ${v1_name} -1"
...
...
bin/varnishtest/vtc_logexp.c
View file @
ec1e6f40
...
...
@@ -142,6 +142,7 @@ struct logexp {
VTAILQ_ENTRY
(
logexp
)
list
;
char
*
name
;
char
*
vname
;
struct
vtclog
*
vl
;
char
run
;
VTAILQ_HEAD
(,
logexp_test
)
tests
;
...
...
@@ -156,7 +157,6 @@ struct logexp {
char
*
query
;
struct
vsm
*
vsm
;
struct
vsb
*
n_arg
;
struct
VSL_data
*
vsl
;
struct
VSLQ
*
vslq
;
pthread_t
tp
;
...
...
@@ -193,15 +193,14 @@ logexp_delete(struct logexp *le)
free
(
le
->
name
);
free
(
le
->
query
);
VSM_Destroy
(
&
le
->
vsm
);
if
(
le
->
n_arg
)
VSB_destroy
(
&
le
->
n_arg
);
FREE_OBJ
(
le
);
}
static
struct
logexp
*
logexp_new
(
const
char
*
name
)
logexp_new
(
const
char
*
name
,
const
char
*
varg
)
{
struct
logexp
*
le
;
struct
vsb
*
vsb
,
*
n_arg
;
ALLOC_OBJ
(
le
,
LOGEXP_MAGIC
);
AN
(
le
);
...
...
@@ -217,6 +216,21 @@ logexp_new(const char *name)
AN
(
le
->
vsl
);
VTAILQ_INSERT_TAIL
(
&
logexps
,
le
,
list
);
REPLACE
(
le
->
vname
,
varg
);
vsb
=
VSB_new_auto
();
AN
(
vsb
);
AZ
(
VSB_printf
(
vsb
,
"${tmpdir}/%s"
,
varg
));
AZ
(
VSB_finish
(
vsb
));
n_arg
=
macro_expand
(
le
->
vl
,
VSB_data
(
vsb
));
VSB_destroy
(
&
vsb
);
if
(
n_arg
==
NULL
)
vtc_fatal
(
le
->
vl
,
"-v argument problems"
);
if
(
VSM_n_Arg
(
le
->
vsm
,
VSB_data
(
n_arg
))
<=
0
)
vtc_fatal
(
le
->
vl
,
"-v argument error: %s"
,
VSM_Error
(
le
->
vsm
));
VSB_destroy
(
&
n_arg
);
return
(
le
);
}
...
...
@@ -376,13 +390,8 @@ logexp_start(struct logexp *le)
AN
(
le
->
vsl
);
AZ
(
le
->
vslq
);
if
(
le
->
n_arg
==
NULL
)
vtc_fatal
(
le
->
vl
,
"-v argument not given"
);
if
(
VSM_n_Arg
(
le
->
vsm
,
VSB_data
(
le
->
n_arg
))
<=
0
)
vtc_fatal
(
le
->
vl
,
"-v argument error: %s"
,
VSM_Error
(
le
->
vsm
));
if
(
VSM_Open
(
le
->
vsm
))
vtc_fatal
(
le
->
vl
,
"VSM_Open: %s"
,
VSM_Error
(
le
->
vsm
));
if
(
VSM_Start
(
le
->
vsm
,
0
,
-
1
))
vtc_fatal
(
le
->
vl
,
"VSM_Start: %s"
,
VSM_Error
(
le
->
vsm
));
AN
(
le
->
vsl
);
c
=
VSL_CursorVSM
(
le
->
vsl
,
le
->
vsm
,
(
le
->
d_arg
?
0
:
VSL_COPT_TAIL
)
|
VSL_COPT_BATCH
);
...
...
@@ -504,8 +513,6 @@ void
cmd_logexpect
(
CMD_ARGS
)
{
struct
logexp
*
le
,
*
le2
;
const
char
tmpdir
[]
=
"${tmpdir}"
;
struct
vsb
*
vsb
;
(
void
)
priv
;
(
void
)
cmd
;
...
...
@@ -532,8 +539,12 @@ cmd_logexpect(CMD_ARGS)
if
(
!
strcmp
(
le
->
name
,
av
[
0
]))
break
;
}
if
(
le
==
NULL
)
le
=
logexp_new
(
av
[
0
]);
if
(
le
==
NULL
)
{
if
(
strcmp
(
av
[
1
],
"-v"
)
||
av
[
2
]
==
NULL
)
vtc_fatal
(
vl
,
"new logexp lacks -v"
);
le
=
logexp_new
(
av
[
0
],
av
[
2
]);
av
+=
2
;
}
av
++
;
for
(;
*
av
!=
NULL
;
av
++
)
{
...
...
@@ -556,18 +567,8 @@ cmd_logexpect(CMD_ARGS)
AZ
(
le
->
run
);
if
(
!
strcmp
(
*
av
,
"-v"
))
{
if
(
av
[
1
]
==
NULL
)
vtc_fatal
(
le
->
vl
,
"Missing -v argument"
);
if
(
le
->
n_arg
!=
NULL
)
VSB_destroy
(
&
le
->
n_arg
);
vsb
=
VSB_new_auto
();
AN
(
vsb
);
AZ
(
VSB_printf
(
vsb
,
"%s/%s"
,
tmpdir
,
av
[
1
]));
AZ
(
VSB_finish
(
vsb
));
le
->
n_arg
=
macro_expand
(
le
->
vl
,
VSB_data
(
vsb
));
VSB_destroy
(
&
vsb
);
if
(
le
->
n_arg
==
NULL
)
return
;
if
(
av
[
1
]
==
NULL
||
strcmp
(
av
[
1
],
le
->
vname
))
vtc_fatal
(
le
->
vl
,
"-v argument cannot change"
);
av
++
;
continue
;
}
...
...
bin/varnishtest/vtc_varnish.c
View file @
ec1e6f40
...
...
@@ -214,6 +214,9 @@ varnishlog_thread(void *priv)
AN
(
vsm
);
(
void
)
VSM_n_Arg
(
vsm
,
v
->
workdir
);
if
(
VSM_Start
(
vsm
,
vtc_maxdur
,
-
1
))
vtc_fatal
(
v
->
vl
,
"vsm|%s"
,
VSM_Error
(
vsm
));
c
=
NULL
;
opt
=
0
;
while
(
v
->
pid
||
c
!=
NULL
)
{
...
...
include/vapi/vsm.h
View file @
ec1e6f40
...
...
@@ -98,6 +98,8 @@ int VSM_n_Arg(struct vsm *vd, const char *n_arg);
* <0 on failure, VSM_Error() returns diagnostic string
*/
int
VSM_Start
(
struct
vsm
*
vd
,
double
patience
,
int
progress_fd
);
const
char
*
VSM_Name
(
const
struct
vsm
*
vd
);
/*
* Return the instance name (-i argument to varnishd)
...
...
lib/libvarnishapi/libvarnishapi.map
View file @
ec1e6f40
...
...
@@ -182,6 +182,7 @@ LIBVARNISHAPI_1.7 {
VSM_invalid;
VSM_valid;
VSM_similar;
VSM_Start;
VSM_Destroy;
VSM_Map;
VSM_Unmap;
...
...
lib/libvarnishapi/vsm.c
View file @
ec1e6f40
...
...
@@ -85,6 +85,8 @@ struct vsm {
uint64_t
age_ok
;
double
t_ok
;
int
started
;
struct
vsc
*
vsc
;
};
...
...
@@ -179,6 +181,7 @@ VSM_n_Arg(struct vsm *vd, const char *arg)
struct
vsb
*
vsb
;
CHECK_OBJ_NOTNULL
(
vd
,
VSM_MAGIC
);
AZ
(
vd
->
started
);
if
(
vd
->
head
)
return
(
vsm_diag
(
vd
,
"VSM_n_Arg: Already open"
));
...
...
@@ -202,6 +205,37 @@ VSM_n_Arg(struct vsm *vd, const char *arg)
/*--------------------------------------------------------------------*/
int
VSM_Start
(
struct
vsm
*
vd
,
double
patience
,
int
progress
)
{
double
t0
;
int
i
,
n
=
0
;
CHECK_OBJ_NOTNULL
(
vd
,
VSM_MAGIC
);
AN
(
vd
->
dname
);
t0
=
VTIM_mono
();
while
(
1
)
{
i
=
VSM_Open
(
vd
);
if
(
patience
<=
0
.
||
i
==
0
)
{
if
(
progress
>=
0
&&
n
>
4
)
(
void
)
write
(
progress
,
"
\n
"
,
1
);
vd
->
started
=
1
;
return
(
i
);
}
if
(
t0
+
patience
<
VTIM_mono
())
{
if
(
progress
>=
0
&&
n
>
4
)
(
void
)
write
(
progress
,
"
\n
"
,
1
);
return
(
vsm_diag
(
vd
,
"Could not get hold of varnishd, is it running?"
));
}
if
(
progress
>=
0
&&
!
(
++
n
%
4
))
(
void
)
write
(
progress
,
"."
,
1
);
VTIM_sleep
(.
25
);
}
}
/*--------------------------------------------------------------------*/
const
char
*
VSM_Name
(
const
struct
vsm
*
vd
)
{
...
...
lib/libvarnishapi/vut.c
View file @
ec1e6f40
...
...
@@ -227,8 +227,6 @@ void
VUT_Setup
(
void
)
{
struct
VSL_cursor
*
c
;
double
t_start
;
int
i
;
AN
(
VUT
.
vsl
);
AZ
(
VUT
.
vsm
);
...
...
@@ -255,45 +253,16 @@ VUT_Setup(void)
AN
(
VUT
.
vsm
);
if
(
VUT
.
n_arg
&&
VSM_n_Arg
(
VUT
.
vsm
,
VUT
.
n_arg
)
<=
0
)
VUT_Error
(
1
,
"%s"
,
VSM_Error
(
VUT
.
vsm
));
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
.)
{
fprintf
(
stderr
,
"Cannot open log -"
" retrying for %.0f seconds
\n
"
,
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
,
"%s"
,
VSM_Error
(
VUT
.
vsm
));
else
VUT_Error
(
1
,
"%s"
,
VSL_Error
(
VUT
.
vsl
));
}
else
if
(
!
isnan
(
t_start
))
fprintf
(
stderr
,
"Log opened
\n
"
);
if
(
VSM_Start
(
VUT
.
vsm
,
VUT
.
t_arg
,
STDERR_FILENO
))
VUT_Error
(
1
,
"VSM: %s"
,
VSM_Error
(
VUT
.
vsm
));
c
=
VSL_CursorVSM
(
VUT
.
vsl
,
VUT
.
vsm
,
(
VUT
.
d_opt
?
VSL_COPT_TAILSTOP
:
VSL_COPT_TAIL
)
|
VSL_COPT_BATCH
);
if
(
c
==
0
)
VUT_Error
(
1
,
"VSL: %s"
,
VSL_Error
(
VUT
.
vsl
));
}
if
(
c
)
VSLQ_SetCursor
(
VUT
.
vslq
,
&
c
);
VSLQ_SetCursor
(
VUT
.
vslq
,
&
c
);
AZ
(
c
);
/* Signal handlers */
...
...
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