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
1f806539
Commit
1f806539
authored
Sep 10, 2016
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Allow multiple VCL labels to point to the same "real" VCL.
parent
2761c436
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
38 deletions
+35
-38
cache_vcl.c
bin/varnishd/cache/cache_vcl.c
+20
-15
mgt_vcl.c
bin/varnishd/mgt/mgt_vcl.c
+15
-23
No files found.
bin/varnishd/cache/cache_vcl.c
View file @
1f806539
...
...
@@ -74,6 +74,7 @@ struct vcl {
VTAILQ_HEAD
(,
backend
)
backend_list
;
VTAILQ_HEAD
(,
vclref
)
ref_list
;
struct
vcl
*
label
;
int
nlabels
;
};
struct
vclref
{
...
...
@@ -258,12 +259,13 @@ vcl_get(struct vcl **vcc, struct vcl *vcl)
AZ
(
errno
=
pthread_rwlock_unlock
(
&
vcl
->
temp_rwl
));
Lck_Lock
(
&
vcl_mtx
);
AN
(
vcl
);
if
(
vcl
->
label
==
NULL
)
if
(
vcl
->
label
==
NULL
)
{
AN
(
strcmp
(
vcl
->
state
,
VCL_TEMP_LABEL
));
*
vcc
=
vcl
;
else
if
(
strcmp
(
vcl
->
state
,
VCL_TEMP_LABEL
))
*
vcc
=
vcl
;
else
}
else
{
AZ
(
strcmp
(
vcl
->
state
,
VCL_TEMP_LABEL
));
*
vcc
=
vcl
->
label
;
}
AN
(
*
vcc
);
AZ
((
*
vcc
)
->
discard
);
(
*
vcc
)
->
busy
++
;
...
...
@@ -804,6 +806,8 @@ vcl_cli_list(struct cli *cli, const char * const *av, void *priv)
struct
vcl
*
vcl
;
const
char
*
flg
;
/* NB: Shall generate same output as mcf_vcl_list() */
(
void
)
av
;
(
void
)
priv
;
ASSERT_CLI
();
...
...
@@ -816,11 +820,12 @@ vcl_cli_list(struct cli *cli, const char * const *av, void *priv)
flg
=
"available"
;
VCLI_Out
(
cli
,
"%-10s %5s/%-8s %6u %s"
,
flg
,
vcl
->
state
,
vcl
->
temp
,
vcl
->
busy
,
vcl
->
loaded_name
);
if
(
vcl
->
label
!=
NULL
)
{
VCLI_Out
(
cli
,
" %s %s"
,
strcmp
(
vcl
->
state
,
VCL_TEMP_LABEL
)
?
"<-"
:
"->"
,
vcl
->
label
->
loaded_name
);
}
if
(
vcl
->
label
!=
NULL
)
VCLI_Out
(
cli
,
" -> %s"
,
vcl
->
label
->
loaded_name
);
else
if
(
vcl
->
nlabels
>
1
)
VCLI_Out
(
cli
,
" (%d labels)"
,
vcl
->
nlabels
);
else
if
(
vcl
->
nlabels
>
0
)
VCLI_Out
(
cli
,
" (%d label)"
,
vcl
->
nlabels
);
VCLI_Out
(
cli
,
"
\n
"
);
}
}
...
...
@@ -874,12 +879,13 @@ vcl_cli_discard(struct cli *cli, const char * const *av, void *priv)
AN
(
vcl
);
// MGT ensures this
Lck_Lock
(
&
vcl_mtx
);
assert
(
vcl
!=
vcl_active
);
// MGT ensures this
AZ
(
vcl
->
nlabels
);
// MGT ensures this
VSC_C_main
->
n_vcl_discard
++
;
VSC_C_main
->
n_vcl_avail
--
;
vcl
->
discard
=
1
;
if
(
vcl
->
label
!=
NULL
)
{
AZ
(
strcmp
(
vcl
->
state
,
VCL_TEMP_LABEL
));
vcl
->
label
->
label
=
NULL
;
vcl
->
label
->
nlabels
--
;
vcl
->
label
=
NULL
;
}
Lck_Unlock
(
&
vcl_mtx
);
...
...
@@ -901,21 +907,20 @@ vcl_cli_label(struct cli *cli, const char * const *av, void *priv)
(
void
)
cli
;
(
void
)
priv
;
vcl
=
vcl_find
(
av
[
3
]);
AN
(
vcl
);
AN
(
vcl
);
// MGT ensures this
lbl
=
vcl_find
(
av
[
2
]);
if
(
lbl
==
NULL
)
{
ALLOC_OBJ
(
lbl
,
VCL_MAGIC
);
AN
(
lbl
);
bprintf
(
lbl
->
state
,
"%s"
,
VCL_TEMP_LABEL
);
lbl
->
temp
=
VCL_TEMP_WARM
;
lbl
->
loaded_name
=
strdup
(
av
[
2
]);
AN
(
lbl
->
loaded_name
);
REPLACE
(
lbl
->
loaded_name
,
av
[
2
]);
VTAILQ_INSERT_TAIL
(
&
vcl_head
,
lbl
,
list
);
}
if
(
lbl
->
label
!=
NULL
)
lbl
->
label
->
label
=
NULL
;
lbl
->
label
->
nlabels
--
;
lbl
->
label
=
vcl
;
vcl
->
label
=
lbl
;
vcl
->
nlabels
++
;
return
;
}
...
...
bin/varnishd/mgt/mgt_vcl.c
View file @
1f806539
...
...
@@ -73,6 +73,7 @@ struct vclprog {
double
go_cold
;
VTAILQ_HEAD
(,
vcldep
)
dfrom
;
VTAILQ_HEAD
(,
vcldep
)
dto
;
int
nto
;
};
static
VTAILQ_HEAD
(,
vclprog
)
vclhead
=
VTAILQ_HEAD_INITIALIZER
(
vclhead
);
...
...
@@ -171,6 +172,7 @@ mgt_vcl_dep_add(struct vclprog *vp_from, struct vclprog *vp_to)
VTAILQ_INSERT_TAIL
(
&
vp_from
->
dfrom
,
vd
,
lfrom
);
vd
->
to
=
vp_to
;
VTAILQ_INSERT_TAIL
(
&
vp_to
->
dto
,
vd
,
lto
);
vp_to
->
nto
++
;
}
static
void
...
...
@@ -180,6 +182,7 @@ mgt_vcl_dep_del(struct vcldep *vd)
CHECK_OBJ_NOTNULL
(
vd
,
VCLDEP_MAGIC
);
VTAILQ_REMOVE
(
&
vd
->
from
->
dfrom
,
vd
,
lfrom
);
VTAILQ_REMOVE
(
&
vd
->
to
->
dto
,
vd
,
lto
);
vd
->
to
->
nto
--
;
FREE_OBJ
(
vd
);
}
...
...
@@ -614,27 +617,15 @@ mcf_vcl_discard(struct cli *cli, const char * const *av, void *priv)
mgt_vcl_del
(
vp
);
}
static
void
mcf_list_labels
(
struct
cli
*
cli
,
const
struct
vclprog
*
vp
)
{
int
n
=
0
;
struct
vcldep
*
vd
;
VTAILQ_FOREACH
(
vd
,
&
vp
->
dto
,
lto
)
{
if
(
n
++
==
5
)
{
VCLI_Out
(
cli
,
" [...]"
);
break
;
}
VCLI_Out
(
cli
,
" %s"
,
vd
->
from
->
name
);
}
}
static
void
__match_proto__
(
cli_func_t
)
mcf_vcl_list
(
struct
cli
*
cli
,
const
char
*
const
*
av
,
void
*
priv
)
{
unsigned
status
;
char
*
p
;
struct
vclprog
*
vp
;
struct
vcldep
*
vd
;
/* NB: Shall generate same output as vcl_cli_list() */
(
void
)
av
;
(
void
)
priv
;
...
...
@@ -652,7 +643,15 @@ mcf_vcl_list(struct cli *cli, const char * const *av, void *priv)
VCLI_Out
(
cli
,
"/%-8s"
,
vp
->
warm
?
VCL_STATE_WARM
:
VCL_STATE_COLD
);
VCLI_Out
(
cli
,
" %6s %s"
,
""
,
vp
->
name
);
mcf_list_labels
(
cli
,
vp
);
if
(
mcf_is_label
(
vp
))
{
vd
=
VTAILQ_FIRST
(
&
vp
->
dfrom
);
AN
(
vd
);
VCLI_Out
(
cli
,
" -> %s"
,
vd
->
to
->
name
);
}
else
if
(
vp
->
nto
>
1
)
{
VCLI_Out
(
cli
,
" (%d labels)"
,
vp
->
nto
);
}
else
if
(
vp
->
nto
>
0
)
{
VCLI_Out
(
cli
,
" (%d label)"
,
vp
->
nto
);
}
VCLI_Out
(
cli
,
"
\n
"
);
}
}
...
...
@@ -680,13 +679,6 @@ mcf_vcl_label(struct cli *cli, const char * const *av, void *priv)
VCLI_Out
(
cli
,
"VCL labels cannot point to labels"
);
return
;
}
if
(
!
VTAILQ_EMPTY
(
&
vpt
->
dto
))
{
VCLI_SetResult
(
cli
,
CLIS_CANT
);
VCLI_Out
(
cli
,
"VCL already labeled with"
);
mcf_list_labels
(
cli
,
vpt
);
VCLI_Out
(
cli
,
"
\n
"
);
return
;
}
vpl
=
mcf_vcl_byname
(
av
[
2
]);
if
(
vpl
!=
NULL
)
{
if
(
!
mcf_is_label
(
vpl
))
{
...
...
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