[PATCH] Do not recognize a 304 as a valid revalidation response for an ims_oc without OF_IMSCAND

Martin Blix Grydeland martin at varnish-software.com
Wed Feb 4 16:12:38 CET 2015


Fixes: #1672
---
 bin/varnishd/cache/cache_fetch.c |  4 +++-
 bin/varnishtest/tests/r01672.vtc | 33 +++++++++++++++++++++++++++++++++
 2 files changed, 36 insertions(+), 1 deletion(-)
 create mode 100644 bin/varnishtest/tests/r01672.vtc

diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 07801e8..79e2c3b 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -393,7 +393,9 @@ vbf_stp_startfetch(struct worker *wrk, struct busyobj *bo)
 
 	AZ(bo->do_esi);
 
-	if (bo->ims_oc != NULL && http_IsStatus(bo->beresp, 304)) {
+	if (bo->ims_oc != NULL &&
+	    ObjCheckFlag(bo->wrk, bo->ims_oc, OF_IMSCAND) &&
+	    http_IsStatus(bo->beresp, 304)) {
 		if (ObjCheckFlag(bo->wrk, bo->ims_oc, OF_CHGGZIP)) {
 			/*
 			 * If we changed the gzip status of the object
diff --git a/bin/varnishtest/tests/r01672.vtc b/bin/varnishtest/tests/r01672.vtc
new file mode 100644
index 0000000..ae99a2f
--- /dev/null
+++ b/bin/varnishtest/tests/r01672.vtc
@@ -0,0 +1,33 @@
+varnishtest "#1672: Bogus 304 backend reply"
+
+# First serve a non-200 status object to the cache,
+# then revalidate it unconditionally
+server s1 {
+	rxreq
+	txresp -status 404
+
+	rxreq
+	txresp -status 304
+} -start
+
+varnish v1 -vcl+backend {
+	sub vcl_backend_response {
+		set beresp.ttl = 0.1s;
+		set beresp.grace = 0s;
+		set beresp.keep = 10s;
+	}
+} -start
+
+client c1 {
+	txreq
+	rxresp
+	expect resp.status == 404
+} -run
+
+delay 0.2
+
+client c1 {
+	txreq
+	rxresp
+	expect resp.status == 304
+} -run
-- 
2.1.4




More information about the varnish-dev mailing list