Commit cc352245 authored by Geoff Simmons's avatar Geoff Simmons

Add an event function, cleans up VDPs and RB tree entries.

parent c75f8919
......@@ -68,3 +68,9 @@ logexpect l1 -v v1 -g vxid -d 1 -q {Error ~ "^vdfp_pipe: vdp f:" or Notice ~ "^v
expect * = Error {^vdfp_pipe: vdp f: /bin/false exited with status \d+$}
expect * = End
} -run
varnish v1 -vcl { backend b None; }
# Tests the discard event, with removal of VDPs.
varnish v1 -cli "vcl.discard vcl1"
varnish v1 -cli "vcl.list"
......@@ -457,6 +457,50 @@ vdp_fini(struct req *req, void **priv)
return (0);
}
/* Event function */
int
vmod_event(VRT_CTX, struct vmod_priv *priv, enum vcl_event_e e)
{
struct vdp_map *map, *prev_map;
ASSERT_CLI();
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
AN(priv);
switch(e) {
case VCL_EVENT_DISCARD:
AN(ctx->vcl);
map = VRBT_MIN(vdp_tree, &tree_h);
while (map != NULL) {
CHECK_OBJ(map, PIPE_VDP_MAP_MAGIC);
prev_map = NULL;
if (map->vcl_name != NULL &&
strcmp(map->vcl_name, VCL_Name(ctx->vcl)) == 0) {
CHECK_OBJ_NOTNULL(map->obj, PIPE_VDP_MAGIC);
if (map->obj->vdp != NULL) {
VRT_RemoveVDP(ctx, map->obj->vdp);
free(map->obj->vdp);
}
prev_map = map;
}
map = VRBT_NEXT(vdp_tree, &tree_h, map);
if (prev_map != NULL) {
VRBT_REMOVE(vdp_tree, &tree_h, map);
FREE_OBJ(map);
}
}
return (0);
case VCL_EVENT_LOAD:
case VCL_EVENT_WARM:
case VCL_EVENT_COLD:
return (0);
default:
WRONG("illegal event enum");
}
NEEDLESS(return (0));
}
/* vdp object */
VCL_VOID
......@@ -545,15 +589,13 @@ vmod_vdp__init(VRT_CTX, struct VPFX(pipe_vdp) **vdpp, const char *obj_name,
return;
}
/* XXX Event function calls VRT_RemoveVDP(), since it needs a VRT_CTX. */
/* Event function calls VRT_RemoveVDP(), since it needs a VRT_CTX. */
VCL_VOID
vmod_vdp__fini(struct VPFX(pipe_vdp) **vdpp)
{
struct VPFX(pipe_vdp) *vdp_obj;
/* XXX cleanup RB tree entry */
if (vdpp == NULL || *vdpp == NULL)
return;
TAKE_OBJ_NOTNULL(vdp_obj, vdpp, PIPE_VDP_MAGIC);
......
......@@ -89,3 +89,5 @@ SEE ALSO
* Varnish: http://www.varnish-cache.org/
* varnishd(1): http://varnish-cache.org/docs/trunk/reference/varnishd.html
* vcl(7): http://varnish-cache.org/docs/trunk/reference/vcl.html
$Event event
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment