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
2ec362a8
Commit
2ec362a8
authored
Sep 08, 2016
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make a convenience function to test if a VCL is a label
parent
169e162c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
11 deletions
+17
-11
mgt_vcl.c
bin/varnishd/mgt/mgt_vcl.c
+17
-11
No files found.
bin/varnishd/mgt/mgt_vcl.c
View file @
2ec362a8
...
...
@@ -148,6 +148,12 @@ mcf_find_no_vcl(struct cli *cli, const char *name)
return
(
1
);
}
static
int
mcf_is_label
(
struct
vclprog
*
vp
)
{
return
(
!
strcmp
(
vp
->
state
,
VCL_STATE_LABEL
));
}
/*--------------------------------------------------------------------*/
static
void
...
...
@@ -383,7 +389,7 @@ mgt_vcl_export_labels(struct vcc *vcc)
{
struct
vclprog
*
vp
;
VTAILQ_FOREACH
(
vp
,
&
vclhead
,
list
)
{
if
(
!
strcmp
(
vp
->
state
,
VCL_STATE_LABEL
))
if
(
mcf_is_label
(
vp
))
VCC_Predef
(
vcc
,
"VCL_VCL"
,
vp
->
name
);
}
}
...
...
@@ -403,7 +409,7 @@ mgt_push_vcls_and_start(struct cli *cli, unsigned *status, char **p)
VTAILQ_FOREACH
(
vp
,
&
vclhead
,
list
)
{
if
(
!
VTAILQ_EMPTY
(
&
vp
->
dfrom
))
continue
;
if
(
!
strcmp
(
vp
->
state
,
VCL_STATE_LABEL
))
if
(
mcf_is_label
(
vp
))
continue
;
if
(
mgt_cli_askchild
(
status
,
p
,
"vcl.load
\"
%s
\"
%s %d%s
\n
"
,
vp
->
name
,
vp
->
fname
,
vp
->
warm
,
vp
->
state
))
...
...
@@ -412,7 +418,7 @@ mgt_push_vcls_and_start(struct cli *cli, unsigned *status, char **p)
*
p
=
NULL
;
}
VTAILQ_FOREACH
(
vp
,
&
vclhead
,
list
)
{
if
(
strcmp
(
vp
->
state
,
VCL_STATE_LABEL
))
if
(
!
mcf_is_label
(
vp
))
continue
;
if
(
mgt_cli_askchild
(
status
,
p
,
"vcl.label %s %s
\n
"
,
vp
->
name
,
vp
->
label
->
name
))
...
...
@@ -423,7 +429,7 @@ mgt_push_vcls_and_start(struct cli *cli, unsigned *status, char **p)
VTAILQ_FOREACH
(
vp
,
&
vclhead
,
list
)
{
if
(
VTAILQ_EMPTY
(
&
vp
->
dfrom
))
continue
;
if
(
!
strcmp
(
vp
->
state
,
VCL_STATE_LABEL
))
if
(
mcf_is_label
(
vp
))
continue
;
if
(
mgt_cli_askchild
(
status
,
p
,
"vcl.load
\"
%s
\"
%s %d%s
\n
"
,
vp
->
name
,
vp
->
fname
,
vp
->
warm
,
vp
->
state
))
...
...
@@ -479,7 +485,7 @@ mcf_vcl_state(struct cli *cli, const char * const *av, void *priv)
if
(
vp
==
NULL
)
return
;
if
(
!
strcmp
(
vp
->
state
,
VCL_STATE_LABEL
))
{
if
(
mcf_is_label
(
vp
))
{
VCLI_Out
(
cli
,
"Labels are always warm"
);
VCLI_SetResult
(
cli
,
CLIS_PARAM
);
return
;
...
...
@@ -571,7 +577,7 @@ mcf_vcl_discard(struct cli *cli, const char * const *av, void *priv)
return
;
}
if
(
!
VTAILQ_EMPTY
(
&
vp
->
dto
))
{
if
(
vp
->
label
!=
NULL
&&
strcmp
(
vp
->
state
,
VCL_STATE_LABEL
))
{
if
(
vp
->
label
!=
NULL
&&
!
mcf_is_label
(
vp
))
{
AN
(
vp
->
warm
);
VCLI_SetResult
(
cli
,
CLIS_PARAM
);
VCLI_Out
(
cli
,
...
...
@@ -593,7 +599,7 @@ mcf_vcl_discard(struct cli *cli, const char * const *av, void *priv)
}
return
;
}
if
(
!
strcmp
(
vp
->
state
,
VCL_STATE_LABEL
))
{
if
(
mcf_is_label
(
vp
))
{
AN
(
vp
->
warm
);
vp
->
label
->
label
=
NULL
;
vp
->
label
=
NULL
;
...
...
@@ -633,8 +639,8 @@ mcf_vcl_list(struct cli *cli, const char * const *av, void *priv)
VCLI_Out
(
cli
,
" %6s %s"
,
""
,
vp
->
name
);
if
(
vp
->
label
!=
NULL
)
VCLI_Out
(
cli
,
" %s %s"
,
strcmp
(
vp
->
state
,
VCL_STATE_LABEL
)
?
"
<-"
:
"->
"
,
vp
->
label
->
name
);
mcf_is_label
(
vp
)
?
"
->"
:
"<-
"
,
vp
->
label
->
name
);
VCLI_Out
(
cli
,
"
\n
"
);
}
}
...
...
@@ -657,7 +663,7 @@ mcf_vcl_label(struct cli *cli, const char * const *av, void *priv)
vpt
=
mcf_find_vcl
(
cli
,
av
[
3
]);
if
(
vpt
==
NULL
)
return
;
if
(
!
strcmp
(
vpt
->
state
,
VCL_STATE_LABEL
))
{
if
(
mcf_is_label
(
vpt
))
{
VCLI_SetResult
(
cli
,
CLIS_PARAM
);
VCLI_Out
(
cli
,
"VCL labels cannot point to labels"
);
return
;
...
...
@@ -670,7 +676,7 @@ mcf_vcl_label(struct cli *cli, const char * const *av, void *priv)
}
vpl
=
mcf_vcl_byname
(
av
[
2
]);
if
(
vpl
!=
NULL
)
{
if
(
strcmp
(
vpl
->
state
,
VCL_STATE_LABEL
))
{
if
(
!
mcf_is_label
(
vpl
))
{
VCLI_SetResult
(
cli
,
CLIS_PARAM
);
VCLI_Out
(
cli
,
"%s is not a label"
,
vpl
->
name
);
return
;
...
...
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