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
f4895da5
Commit
f4895da5
authored
Jan 11, 2016
by
Poul-Henning Kamp
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Split VCL event sender functions out individually.
Dridi: Not XXX comments
parent
bef42fa7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
56 additions
and
31 deletions
+56
-31
cache_vcl.c
bin/varnishd/cache/cache_vcl.c
+56
-31
No files found.
bin/varnishd/cache/cache_vcl.c
View file @
f4895da5
...
...
@@ -411,50 +411,75 @@ VRT_rel_vcl(VRT_CTX)
Lck_Unlock
(
&
vcl_mtx
);
}
/*--------------------------------------------------------------------*/
/*--------------------------------------------------------------------
* Wrapper functions to send events to VCL and guarantee semantics.
*/
static
struct
vcl
*
vcl_
find
(
const
char
*
name
)
static
int
vcl_
event_load
(
VRT_CTX
)
{
struct
vcl
*
vcl
;
ASSERT_CLI
();
VTAILQ_FOREACH
(
vcl
,
&
vcl_head
,
list
)
{
if
(
vcl
->
discard
)
continue
;
if
(
!
strcmp
(
vcl
->
loaded_name
,
name
))
return
(
vcl
);
}
return
(
NULL
);
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
AN
(
ctx
->
handling
);
AN
(
ctx
->
vcl
);
AN
(
ctx
->
msg
);
return
(
ctx
->
vcl
->
conf
->
event_vcl
(
ctx
,
VCL_EVENT_LOAD
));
}
static
int
vcl_
setup_event
(
VRT_CTX
,
enum
vcl_event_e
ev
)
vcl_
event_warm
(
VRT_CTX
)
{
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
AN
(
ctx
->
handling
);
AN
(
ctx
->
vcl
);
assert
(
ev
==
VCL_EVENT_LOAD
||
ev
==
VCL_EVENT_WARM
||
ev
==
VCL_EVENT_USE
);
if
(
ev
==
VCL_EVENT_LOAD
)
AN
(
ctx
->
msg
);
// AN/AZ(ctx->msg); // XXX: Dridi: which is it ?
return
(
ctx
->
vcl
->
conf
->
event_vcl
(
ctx
,
VCL_EVENT_WARM
));
}
return
(
ctx
->
vcl
->
conf
->
event_vcl
(
ctx
,
ev
));
static
int
vcl_event_use
(
VRT_CTX
)
{
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
AN
(
ctx
->
handling
);
AN
(
ctx
->
vcl
);
AN
(
ctx
->
msg
);
return
(
ctx
->
vcl
->
conf
->
event_vcl
(
ctx
,
VCL_EVENT_USE
));
}
static
void
vcl_
failsafe_event
(
VRT_CTX
,
enum
vcl_event_e
ev
)
vcl_
event_cold
(
VRT_CTX
)
{
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
AN
(
ctx
->
handling
);
AN
(
ctx
->
vcl
);
AZ
(
ctx
->
msg
);
AZ
(
ctx
->
vcl
->
conf
->
event_vcl
(
ctx
,
VCL_EVENT_COLD
));
}
static
void
vcl_event_discard
(
VRT_CTX
)
{
CHECK_OBJ_NOTNULL
(
ctx
,
VRT_CTX_MAGIC
);
AN
(
ctx
->
handling
);
AN
(
ctx
->
vcl
);
assert
(
ev
==
VCL_EVENT_COLD
||
ev
==
VCL_EVENT_DISCARD
);
// AN/AZ(ctx->msg); // XXX: Dridi: which is it ?
AZ
(
ctx
->
vcl
->
conf
->
event_vcl
(
ctx
,
VCL_EVENT_DISCARD
));
}
/*--------------------------------------------------------------------*/
static
struct
vcl
*
vcl_find
(
const
char
*
name
)
{
struct
vcl
*
vcl
;
if
(
ctx
->
vcl
->
conf
->
event_vcl
(
ctx
,
ev
)
!=
0
)
WRONG
(
"A VMOD cannot fail COLD or DISCARD events"
);
ASSERT_CLI
();
VTAILQ_FOREACH
(
vcl
,
&
vcl_head
,
list
)
{
if
(
vcl
->
discard
)
continue
;
if
(
!
strcmp
(
vcl
->
loaded_name
,
name
))
return
(
vcl
);
}
return
(
NULL
);
}
static
void
...
...
@@ -477,7 +502,7 @@ vcl_set_state(VRT_CTX, const char *state)
vcl
->
temp
=
vcl
->
refcount
?
VCL_TEMP_COOLING
:
VCL_TEMP_COLD
;
vcl_
failsafe_event
(
ctx
,
VCL_EVENT_COLD
);
vcl_
event_cold
(
ctx
);
vcl_BackendEvent
(
vcl
,
VCL_EVENT_COLD
);
}
else
if
(
vcl
->
busy
)
...
...
@@ -494,7 +519,7 @@ vcl_set_state(VRT_CTX, const char *state)
/* The VCL must first reach a stable cold state */
else
if
(
vcl
->
temp
!=
VCL_TEMP_COOLING
)
{
vcl
->
temp
=
VCL_TEMP_WARM
;
(
void
)
vcl_setup_event
(
ctx
,
VCL_EVENT_WARM
);
vcl_event_warm
(
ctx
);
// XXX: Dridi: what if it fails?
vcl_BackendEvent
(
vcl
,
VCL_EVENT_WARM
);
}
break
;
...
...
@@ -544,13 +569,13 @@ VCL_Load(struct cli *cli, const char *name, const char *fn, const char *state)
VSB_clear
(
vsb
);
ctx
.
msg
=
vsb
;
i
=
vcl_
setup_event
(
&
ctx
,
VCL_EVENT_LOAD
);
i
=
vcl_
event_load
(
&
ctx
);
AZ
(
VSB_finish
(
vsb
));
if
(
i
)
{
VCLI_Out
(
cli
,
"VCL
\"
%s
\"
Failed initialization"
,
name
);
if
(
VSB_len
(
vsb
))
VCLI_Out
(
cli
,
"
\n
Message:
\n\t
%s"
,
VSB_data
(
vsb
));
vcl_
failsafe_event
(
&
ctx
,
VCL_EVENT_DISCARD
);
vcl_
event_discard
(
&
ctx
);
vcl_KillBackends
(
vcl
);
VCL_Close
(
&
vcl
);
VSB_delete
(
vsb
);
...
...
@@ -592,7 +617,7 @@ VCL_Nuke(struct vcl *vcl)
ctx
.
method
=
VCL_MET_FINI
;
ctx
.
handling
=
&
hand
;
ctx
.
vcl
=
vcl
;
vcl_
failsafe_event
(
&
ctx
,
VCL_EVENT_DISCARD
);
vcl_
event_discard
(
&
ctx
);
vcl_KillBackends
(
vcl
);
free
(
vcl
->
loaded_name
);
VCL_Close
(
&
vcl
);
...
...
@@ -717,7 +742,7 @@ ccf_config_use(struct cli *cli, const char * const *av, void *priv)
AN
(
vsb
);
ctx
.
msg
=
vsb
;
ctx
.
vcl
=
vcl
;
i
=
vcl_
setup_event
(
&
ctx
,
VCL_EVENT_USE
);
i
=
vcl_
event_use
(
&
ctx
);
AZ
(
VSB_finish
(
vsb
));
if
(
i
)
{
VCLI_Out
(
cli
,
"VCL
\"
%s
\"
Failed to activate"
,
av
[
2
]);
...
...
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