[experimental-ims] a39f3ee Reset bereq http struct on restart from vcl_miss and vcl_pass

Geoff Simmons geoff at varnish-cache.org
Wed Aug 31 16:00:13 CEST 2011


commit a39f3ee67c0a88bb3b5a0b97a9070bcc6a11f92a
Author: Tollef Fog Heen <tfheen at varnish-software.com>
Date:   Tue Aug 2 14:55:21 2011 +0200

    Reset bereq http struct on restart from vcl_miss and vcl_pass
    
    Thanks a lot to David for minimised test case showing the bug.
    
    Fixes: #965

diff --git a/bin/varnishd/cache_center.c b/bin/varnishd/cache_center.c
index 4bac471..eb0af3e 100644
--- a/bin/varnishd/cache_center.c
+++ b/bin/varnishd/cache_center.c
@@ -1155,6 +1155,7 @@ cnt_miss(struct sess *sp)
 	case VCL_RET_ERROR:
 		AZ(HSH_Deref(sp->wrk, sp->objcore, NULL));
 		sp->objcore = NULL;
+		http_Setup(sp->wrk->bereq, NULL);
 		sp->step = STP_ERROR;
 		return (0);
 	case VCL_RET_PASS:
@@ -1223,6 +1224,7 @@ cnt_pass(struct sess *sp)
 	sp->wrk->between_bytes_timeout = 0;
 	VCL_pass_method(sp);
 	if (sp->handling == VCL_RET_ERROR) {
+		http_Setup(sp->wrk->bereq, NULL);
 		sp->step = STP_ERROR;
 		return (0);
 	}
diff --git a/bin/varnishtest/tests/r00965.vtc b/bin/varnishtest/tests/r00965.vtc
new file mode 100644
index 0000000..f8228a9
--- /dev/null
+++ b/bin/varnishtest/tests/r00965.vtc
@@ -0,0 +1,52 @@
+varnishtest "restart in vcl_miss #965"
+
+server s1 {
+	rxreq
+	txresp
+} -start
+
+varnish v1 -vcl+backend {
+	sub vcl_recv {
+		if (req.http.X-Banned == "check") { remove req.http.X-Banned; }
+		elseif (req.restarts == 0) {
+		        set req.http.X-Banned = "check";
+			if (req.http.x-pass) {
+				return (pass);
+			} else {
+				return (lookup);
+			}
+		}
+	}
+
+	sub vcl_hash {
+		## Check if they have a ban in the cache, or if they are going to be banned in cache.
+		if (req.http.X-Banned) {
+			hash_data(client.ip);
+			return (hash);
+		}
+	}
+
+	sub vcl_error {
+		if (obj.status == 988) { return (restart); }
+	}
+
+	sub vcl_miss {
+		if (req.http.X-Banned == "check") { error 988 "restarting"; }
+	}
+
+	sub vcl_pass {
+		if (req.http.X-Banned == "check") { error 988 "restarting"; }
+	}
+} -start
+
+client c1 {
+	txreq
+	rxresp
+	expect resp.status == 200
+	txreq
+	rxresp
+	expect resp.status == 200
+	txreq -hdr "X-Pass: 1"
+	rxresp
+	expect resp.status == 200
+} -run



More information about the varnish-commit mailing list