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
f6abce43
Commit
f6abce43
authored
Feb 12, 2019
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor our "call into VCL" code a little
parent
5735a543
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
17 additions
and
11 deletions
+17
-11
cache_director.c
bin/varnishd/cache/cache_director.c
+2
-2
cache_varnishd.h
bin/varnishd/cache/cache_varnishd.h
+1
-1
cache_vcl.c
bin/varnishd/cache/cache_vcl.c
+14
-8
No files found.
bin/varnishd/cache/cache_director.c
View file @
f6abce43
...
...
@@ -298,7 +298,7 @@ do_list(struct cli *cli, struct director *d, void *priv)
if
(
d
->
vdir
->
admin_health
==
VDI_AH_DELETED
)
return
(
0
);
ctx
=
VCL_Get_CliCtx
(
0
,
0
);
ctx
=
VCL_Get_CliCtx
(
0
);
// XXX admin health "probe" for the no-probe case is confusing
VCLI_Out
(
cli
,
"
\n
%-*s %-*s "
,
...
...
@@ -333,7 +333,7 @@ do_list_json(struct cli *cli, struct director *d, void *priv)
if
(
d
->
vdir
->
admin_health
==
VDI_AH_DELETED
)
return
(
0
);
ctx
=
VCL_Get_CliCtx
(
0
,
0
);
ctx
=
VCL_Get_CliCtx
(
0
);
VCLI_Out
(
cli
,
"%s"
,
la
->
jsep
);
la
->
jsep
=
",
\n
"
;
...
...
bin/varnishd/cache/cache_varnishd.h
View file @
f6abce43
...
...
@@ -389,7 +389,7 @@ const char *VCL_Return_Name(unsigned);
const
char
*
VCL_Method_Name
(
unsigned
);
void
VCL_Bo2Ctx
(
struct
vrt_ctx
*
,
struct
busyobj
*
);
void
VCL_Req2Ctx
(
struct
vrt_ctx
*
,
struct
req
*
);
struct
vrt_ctx
*
VCL_Get_CliCtx
(
unsigned
,
int
);
struct
vrt_ctx
*
VCL_Get_CliCtx
(
int
);
void
VCL_Rel_CliCtx
(
struct
vrt_ctx
**
);
#define VCL_MET_MAC(l,u,t,b) \
...
...
bin/varnishd/cache/cache_vcl.c
View file @
f6abce43
...
...
@@ -109,7 +109,7 @@ VCL_Req2Ctx(struct vrt_ctx *ctx, struct req *req)
/*--------------------------------------------------------------------*/
struct
vrt_ctx
*
VCL_Get_CliCtx
(
unsigned
method
,
int
msg
)
VCL_Get_CliCtx
(
int
msg
)
{
ASSERT_CLI
();
...
...
@@ -117,7 +117,6 @@ VCL_Get_CliCtx(unsigned method, int msg)
INIT_OBJ
(
&
ctx_cli
,
VRT_CTX_MAGIC
);
handling_cli
=
0
;
ctx_cli
.
handling
=
&
handling_cli
;
ctx_cli
.
method
=
method
;
ctx_cli
.
now
=
VTIM_real
();
if
(
msg
)
{
ctx_cli
.
msg
=
VSB_new_auto
();
...
...
@@ -158,6 +157,8 @@ vcl_send_event(VRT_CTX, enum vcl_event_e ev)
ev
==
VCL_EVENT_WARM
||
ev
==
VCL_EVENT_COLD
||
ev
==
VCL_EVENT_DISCARD
);
assert
(
ev
!=
VCL_EVENT_LOAD
||
ctx
->
method
==
VCL_MET_INIT
);
assert
(
ev
!=
VCL_EVENT_DISCARD
||
ctx
->
method
==
VCL_MET_FINI
);
AN
(
ctx
->
handling
);
*
ctx
->
handling
=
0
;
AN
(
ctx
->
ws
);
...
...
@@ -533,7 +534,8 @@ vcl_set_state(VRT_CTX, const char *state)
}
static
void
vcl_cancel_load
(
VRT_CTX
,
struct
cli
*
cli
,
const
char
*
name
,
const
char
*
step
)
vcl_cancel_load
(
struct
vrt_ctx
*
ctx
,
struct
cli
*
cli
,
const
char
*
name
,
const
char
*
step
)
{
struct
vcl
*
vcl
=
ctx
->
vcl
;
...
...
@@ -545,8 +547,9 @@ vcl_cancel_load(VRT_CTX, struct cli *cli, const char *name, const char *step)
VCLI_Out
(
cli
,
"VCL
\"
%s
\"
Failed %s"
,
name
,
step
);
if
(
VSB_len
(
ctx
->
msg
))
VCLI_Out
(
cli
,
"
\n
Message:
\n\t
%s"
,
VSB_data
(
ctx
->
msg
));
*
ctx
->
handling
=
0
;
ctx
->
method
=
VCL_MET_FINI
;
AZ
(
vcl_send_event
(
ctx
,
VCL_EVENT_DISCARD
));
ctx
->
method
=
0
;
vcl_KillBackends
(
vcl
);
free
(
vcl
->
loaded_name
);
VCL_Close
(
&
vcl
);
...
...
@@ -584,7 +587,9 @@ vcl_load(struct cli *cli, struct vrt_ctx *ctx,
ctx
->
vcl
=
vcl
;
VSB_clear
(
ctx
->
msg
);
ctx
->
method
=
VCL_MET_INIT
;
i
=
vcl_send_event
(
ctx
,
VCL_EVENT_LOAD
);
ctx
->
method
=
0
;
if
(
i
||
*
ctx
->
handling
!=
VCL_RET_OK
)
{
vcl_cancel_load
(
ctx
,
cli
,
name
,
"initialization"
);
return
;
...
...
@@ -616,7 +621,7 @@ VCL_Poll(void)
struct
vcl
*
vcl
,
*
vcl2
;
ASSERT_CLI
();
ctx
=
VCL_Get_CliCtx
(
0
,
0
);
ctx
=
VCL_Get_CliCtx
(
0
);
VTAILQ_FOREACH_SAFE
(
vcl
,
&
vcl_head
,
list
,
vcl2
)
{
if
(
vcl
->
temp
==
VCL_TEMP_BUSY
||
vcl
->
temp
==
VCL_TEMP_COOLING
)
{
...
...
@@ -630,10 +635,11 @@ VCL_Poll(void)
assert
(
vcl
!=
vcl_active
);
assert
(
VTAILQ_EMPTY
(
&
vcl
->
ref_list
));
VTAILQ_REMOVE
(
&
vcl_head
,
vcl
,
list
);
ctx
->
method
=
VCL_MET_FINI
;
ctx
->
vcl
=
vcl
;
ctx
->
syntax
=
ctx
->
vcl
->
conf
->
syntax
;
ctx
->
method
=
VCL_MET_FINI
;
AZ
(
vcl_send_event
(
ctx
,
VCL_EVENT_DISCARD
));
ctx
->
method
=
0
;
vcl_KillBackends
(
vcl
);
free
(
vcl
->
loaded_name
);
VCL_Close
(
&
vcl
);
...
...
@@ -732,7 +738,7 @@ vcl_cli_load(struct cli *cli, const char * const *av, void *priv)
AZ
(
priv
);
ASSERT_CLI
();
ctx
=
VCL_Get_CliCtx
(
VCL_MET_INIT
,
1
);
ctx
=
VCL_Get_CliCtx
(
1
);
vcl_load
(
cli
,
ctx
,
av
[
2
],
av
[
3
],
av
[
4
]);
VCL_Rel_CliCtx
(
&
ctx
);
}
...
...
@@ -746,7 +752,7 @@ vcl_cli_state(struct cli *cli, const char * const *av, void *priv)
ASSERT_CLI
();
AN
(
av
[
2
]);
AN
(
av
[
3
]);
ctx
=
VCL_Get_CliCtx
(
0
,
1
);
ctx
=
VCL_Get_CliCtx
(
1
);
ctx
->
vcl
=
vcl_find
(
av
[
2
]);
AN
(
ctx
->
vcl
);
// MGT ensures this
if
(
vcl_set_state
(
ctx
,
av
[
3
]))
{
...
...
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