[master] b26ba7d Always consume the request body in bgfetch

Federico G. Schwindt fgsch at lodoss.net
Fri Sep 30 10:41:05 CEST 2016


commit b26ba7d9890649edfe88a99a67a1ff799940f282
Author: Federico G. Schwindt <fgsch at lodoss.net>
Date:   Fri Sep 30 09:35:08 2016 +0100

    Always consume the request body in bgfetch
    
    Fixes #2105. Minor test cleanups while here.

diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 405317c..40664b4 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -1071,6 +1071,7 @@ VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc,
 		bo = NULL; /* ref transferred to fetch thread */
 		if (mode == VBF_BACKGROUND) {
 			ObjWaitState(oc, BOS_REQ_DONE);
+			VRB_Ignore(req);
 		} else {
 			ObjWaitState(oc, BOS_STREAM);
 			if (oc->boc->state == BOS_FAILED) {
diff --git a/bin/varnishtest/tests/r01927.vtc b/bin/varnishtest/tests/r01927.vtc
index c6769df..d1478c6 100644
--- a/bin/varnishtest/tests/r01927.vtc
+++ b/bin/varnishtest/tests/r01927.vtc
@@ -13,21 +13,15 @@ server s1 {
 
 varnish v1 -vcl+backend {
 	sub vcl_recv {
-		set req.http.X-Method = req.method;
-		# We ignore the actual body and verb for this test.
+		# We ignore the actual body for this test.
+		set req.http.method = req.method;
 		return (hash);
 	}
-	sub vcl_miss {
-		return (fetch);
-	}
 	sub vcl_backend_fetch {
-		set bereq.method = bereq.http.X-Method;
-		unset bereq.http.X-Method;
-		set bereq.first_byte_timeout = 1s;
+		set bereq.method = bereq.http.method;
 	}
 	sub vcl_backend_response {
-		set beresp.ttl = 1s;
-		set beresp.grace = 2s;
+		set beresp.ttl = 0.5s;
 	}
 } -start
 
@@ -38,7 +32,7 @@ client c1 {
 	txreq -req "POST" -body "foo"
 	rxresp
 	expect resp.body == "bar"
-	delay 1
+	delay 0.5
 	txreq -req "POST" -body "foo"
 	rxresp
 	expect resp.body == "bar"
diff --git a/bin/varnishtest/tests/r02105.vtc b/bin/varnishtest/tests/r02105.vtc
new file mode 100644
index 0000000..5834c11
--- /dev/null
+++ b/bin/varnishtest/tests/r02105.vtc
@@ -0,0 +1,29 @@
+varnishtest "Always consume the request body in bgfetch"
+
+server s1 {
+	rxreq
+	expect req.bodylen == 0
+	txresp
+	rxreq
+	expect req.bodylen == 0
+	txresp
+} -start
+
+varnish v1 -vcl+backend {
+	sub vcl_backend_response {
+		set beresp.ttl = 0.5s;
+	}
+} -start
+
+client c1 {
+	txreq -bodylen 10
+	rxresp
+	expect resp.status == 200
+	delay 1
+	txreq -bodylen 10
+	rxresp
+	expect resp.status == 200
+	txreq -bodylen 10
+	rxresp
+	expect resp.status == 200
+} -run



More information about the varnish-commit mailing list