[master] 1dc303a The vcl_purge{} method can return synth or restart.

Poul-Henning Kamp phk at FreeBSD.org
Mon May 12 10:57:15 CEST 2014


commit 1dc303aac59deb4ec1ed0e9b491f4016aba2bcfb
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Mon May 12 08:55:50 2014 +0000

    The vcl_purge{} method can return synth or restart.
    
    (Remember to change the "PURGE" to "GET" if you do this.)
    
    Fixes #1493

diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index d60c136..9ebad3f 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -830,7 +830,16 @@ cnt_purge(struct worker *wrk, struct req *req)
 	AZ(HSH_DerefObjCore(&wrk->stats, &boc));
 
 	VCL_purge_method(req->vcl, wrk, req, NULL, req->http->ws);
-	req->req_step = R_STP_SYNTH;
+	switch (wrk->handling) {
+	case VCL_RET_RESTART:
+		req->req_step = R_STP_RESTART;
+		break;
+	case VCL_RET_SYNTH:
+		req->req_step = R_STP_SYNTH;
+		break;
+	default:
+		WRONG("Illegal return from vcl_purge{}");
+	}
 	return (REQ_FSM_MORE);
 }
 
diff --git a/bin/varnishtest/tests/r01493.vtc b/bin/varnishtest/tests/r01493.vtc
new file mode 100644
index 0000000..f27d899
--- /dev/null
+++ b/bin/varnishtest/tests/r01493.vtc
@@ -0,0 +1,24 @@
+varnishtest "restart in vcl_purge"
+
+server s1 {
+	rxreq
+	txresp
+} -start
+
+varnish v1 -vcl+backend {
+	sub vcl_recv {
+		if (req.method == "PURGE") {
+			return (purge);
+		}
+	}
+	sub vcl_purge {
+		set req.method = "GET";
+		return (restart);
+	}
+} -start
+
+client c1 {
+	txreq -req PURGE
+	rxresp
+	expect resp.status == 200
+} -run
diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py
index 1e523f1..c3b51ff 100755
--- a/lib/libvcc/generate.py
+++ b/lib/libvcc/generate.py
@@ -100,7 +100,7 @@ returns =(
 	),
 	('purge',
 		"C",
-		('synth', 'fetch',)
+		('synth', 'restart',)
 	),
 	('miss',
 		"C",



More information about the varnish-commit mailing list