[6.0] b501bb064 Ensure we don't recycle a closed backend connection

Reza Naghibi reza at naghibi.com
Wed May 20 13:54:08 UTC 2020


commit b501bb06489a6458a13d17d726a9339a8431b995
Author: Dag Haavi Finstad <daghf at varnish-software.com>
Date:   Wed Apr 1 15:52:31 2020 +0200

    Ensure we don't recycle a closed backend connection
    
    Fixes: #3266

diff --git a/bin/varnishd/http1/cache_http1_vfp.c b/bin/varnishd/http1/cache_http1_vfp.c
index 36228cc44..7b03ca8ce 100644
--- a/bin/varnishd/http1/cache_http1_vfp.c
+++ b/bin/varnishd/http1/cache_http1_vfp.c
@@ -80,6 +80,9 @@ v1f_read(const struct vfp_ctx *vc, struct http_conn *htc, void *d, ssize_t len)
 			    "%s", strerror(errno));
 			return (i);
 		}
+		if (i == 0)
+			htc->doclose = SC_RESP_CLOSE;
+
 	}
 	return (i + l);
 }
diff --git a/bin/varnishtest/tests/r03266.vtc b/bin/varnishtest/tests/r03266.vtc
new file mode 100644
index 000000000..1c4718192
--- /dev/null
+++ b/bin/varnishtest/tests/r03266.vtc
@@ -0,0 +1,19 @@
+varnishtest "Don't recycle a closed backend connection"
+
+# broken origin: sends eof-encoded HTTP/1.1 response
+server s1 {
+	rxreq
+	send "HTTP/1.1 200 OK\r\n\r\n"
+	send "foobar"
+} -start
+
+varnish v1 -vcl+backend {} -start
+
+client c1 {
+	txreq
+	rxresp
+} -run
+
+varnish v1 -expect fetch_failed == 0
+varnish v1 -expect fetch_eof == 1
+varnish v1 -expect backend_recycle == 0


More information about the varnish-commit mailing list