[4.0] ee92500 Remove the stand-alone "purge" action from VCL, now that we have return(purge) from vcl_recv.

Poul-Henning Kamp phk at FreeBSD.org
Tue Jun 24 11:31:46 CEST 2014


commit ee9250095af04b74c31ca769a55da3d18a6eeb7d
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue May 13 07:10:11 2014 +0000

    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.

diff --git a/bin/varnishd/cache/cache_vrt.c b/bin/varnishd/cache/cache_vrt.c
index 4e1bcbf..08e3b77 100644
--- a/bin/varnishd/cache/cache_vrt.c
+++ b/bin/varnishd/cache/cache_vrt.c
@@ -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);
 }
 
 /*--------------------------------------------------------------------
diff --git a/bin/varnishtest/tests/c00041.vtc b/bin/varnishtest/tests/c00041.vtc
index 2b7efc2..bd6abdb 100644
--- a/bin/varnishtest/tests/c00041.vtc
+++ b/bin/varnishtest/tests/c00041.vtc
@@ -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; } }
-}
diff --git a/include/vrt.h b/include/vrt.h
index 8e5acba..bfbbb2d 100644
--- a/include/vrt.h
+++ b/include/vrt.h
@@ -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 *);
diff --git a/lib/libvcc/vcc_action.c b/lib/libvcc/vcc_action.c
index b06ff3d..910a89c 100644
--- a/lib/libvcc/vcc_action.c
+++ b/lib/libvcc/vcc_action.c
@@ -367,16 +367,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)
 {
 	vcc_NextToken(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 },



More information about the varnish-commit mailing list