Commit ee925009 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Remove the stand-alone "purge" action from VCL, now that we have

return(purge) from vcl_recv.

Retain the VRT_purge() for VMOD and inline-C use.
parent 578366ec
......@@ -480,11 +480,11 @@ VRT_CacheReqBody(const struct vrt_ctx *ctx, long long maxsize)
}
/*--------------------------------------------------------------------
* "real" purges
* purges
*/
void
VRT_purge(const struct vrt_ctx *ctx, double ttl, double grace)
VRT_purge(const struct vrt_ctx *ctx, double ttl, double grace, double keep)
{
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
......@@ -492,10 +492,10 @@ VRT_purge(const struct vrt_ctx *ctx, double ttl, double grace)
CHECK_OBJ_NOTNULL(ctx->req->wrk, WORKER_MAGIC);
if (ctx->method == VCL_MET_HIT)
HSH_Purge(ctx->req->wrk, ctx->req->obj->objcore->objhead,
ttl, grace, NAN);
ttl, grace, keep);
else if (ctx->method == VCL_MET_MISS)
HSH_Purge(ctx->req->wrk, ctx->req->objcore->objhead,
ttl, grace, NAN);
ttl, grace, keep);
}
/*--------------------------------------------------------------------
......
......@@ -39,8 +39,12 @@ server s1 {
} -start
varnish v1 -vcl+backend {
sub vcl_miss { if (req.http.purge == "yes") { purge; } }
sub vcl_hit { if (req.http.purge == "yes") { purge; return(restart);} }
sub vcl_recv { if (req.http.purge == "yes") { return(purge); } }
sub vcl_purge { if (req.http.restart == "yes") {
unset req.http.purge;
unset req.http.restart;
return(restart);}
}
} -start
client c1 {
......@@ -49,6 +53,7 @@ client c1 {
expect resp.status == 200
expect resp.http.x-varnish == 1001
expect resp.bodylen == 1
delay .1
txreq -url "/1" -hdr "Foo: foo2"
rxresp
......@@ -62,42 +67,44 @@ client c1 {
expect resp.status == 200
expect resp.http.x-varnish == "1005 1002"
expect resp.bodylen == 1
delay .1
txreq -url "/1" -hdr "Foo: foo2"
rxresp
expect resp.status == 200
expect resp.http.x-varnish == "1006 1004"
expect resp.bodylen == 2
delay .1
# Purge on hit
txreq -url "/1" -hdr "Foo: foo2" -hdr "purge: yes"
txreq -url "/1" -hdr "Foo: foo2" -hdr "purge: yes" -hdr "restart: yes"
rxresp
expect resp.status == 200
expect resp.bodylen == 12
delay .1
txreq -url "/1" -hdr "foo: foo1"
rxresp
expect resp.status == 200
expect resp.bodylen == 11
delay .1
# Purge on miss
txreq -url "/1" -hdr "Foo: foo3" -hdr "purge: yes"
txreq -url "/1" -hdr "Foo: foo3" -hdr "purge: yes" -hdr "restart: yes"
rxresp
expect resp.status == 200
expect resp.bodylen == 23
delay .1
txreq -url "/1" -hdr "foo: foo1"
rxresp
expect resp.status == 200
expect resp.bodylen == 21
delay .1
txreq -url "/1" -hdr "Foo: foo2"
rxresp
expect resp.status == 200
expect resp.bodylen == 22
delay .1
} -run
varnish v1 -errvcl {'purge': not a valid action in method 'vcl_recv'.} {
backend s1 { .host = "${s1_addr}"; }
sub vcl_recv { if (req.http.purge == "yes") { purge; } }
}
......@@ -201,7 +201,7 @@ const char *VRT_regsub(const struct vrt_ctx *, int all, const char *,
void *, const char *);
void VRT_ban_string(const struct vrt_ctx *, const char *);
void VRT_purge(const struct vrt_ctx *, double ttl, double grace);
void VRT_purge(const struct vrt_ctx *, double ttl, double grace, double keep);
void VRT_count(const struct vrt_ctx *, unsigned);
int VRT_rewrite(const char *, const char *);
......
......@@ -366,16 +366,6 @@ parse_rollback(struct vcc *tl)
/*--------------------------------------------------------------------*/
static void
parse_purge(struct vcc *tl)
{
vcc_NextToken(tl);
Fb(tl, 1, "VRT_purge(ctx, 0, 0);\n");
}
/*--------------------------------------------------------------------*/
static void
parse_synthetic(struct vcc *tl)
{
......@@ -409,7 +399,6 @@ static struct action_table {
{ "call", parse_call },
{ "hash_data", parse_hash_data, VCL_MET_HASH },
{ "new", parse_new, VCL_MET_INIT},
{ "purge", parse_purge, VCL_MET_MISS | VCL_MET_HIT },
{ "return", parse_return },
{ "rollback", parse_rollback },
{ "set", parse_set },
......
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