[master] f8110c0 Deal with fetch failures in ved_stripgzip

Martin Blix Grydeland martin at varnish-software.com
Tue Jun 14 17:13:09 CEST 2016


commit f8110c098e0da201bf322699d5e366a9d64724bd
Author: Martin Blix Grydeland <martin at varnish-software.com>
Date:   Mon May 23 14:31:36 2016 +0200

    Deal with fetch failures in ved_stripgzip
    
    An object failing fetch that is waited upon by the ESI delivery code
    would cause asserts finding an empty object. If waiting for an object,
    check the status of the object and deliver zero bytes if failed.
    
    Fixes: #1953

diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c
index fa944d0..59323ef 100644
--- a/bin/varnishd/cache/cache_esi_deliver.c
+++ b/bin/varnishd/cache/cache_esi_deliver.c
@@ -711,6 +711,11 @@ ved_stripgzip(struct req *req, const struct boc *boc)
 	/* OA_GZIPBITS is not valid until BOS_FINISHED */
 	if (boc != NULL)
 		ObjWaitState(req->objcore, BOS_FINISHED);
+	if (req->objcore->flags & OC_F_FAILED) {
+		/* No way of signalling errors in the middle of
+		   the ESI body. Omit this ESI fragment. */
+		return;
+	}
 
 	AN(ObjCheckFlag(req->wrk, req->objcore, OF_GZIPED));
 
diff --git a/bin/varnishtest/tests/r01953.vtc b/bin/varnishtest/tests/r01953.vtc
new file mode 100644
index 0000000..b456782
--- /dev/null
+++ b/bin/varnishtest/tests/r01953.vtc
@@ -0,0 +1,29 @@
+varnishtest "#1953: ved_stripgzip and failed object"
+
+server s1 {
+	rxreq
+	txresp -gzipbody {<1><esi:include src="/2"/></1>}
+
+	rxreq
+	txresp -nolen -hdr "Content-Encoding: gzip" -hdr "Content-Length: 42"
+	# No body sent, will cause fetch error
+	# The delay allows time for the ESI deliver thread to get to the point
+	# where it is waiting for this body
+	delay 1
+} -start
+
+varnish v1 -vcl+backend {
+	sub vcl_backend_response {
+		if (bereq.url == "/") {
+			set beresp.do_esi = true;
+		}
+	}
+} -start
+
+client c1 {
+	txreq -hdr "Accept-Encoding: gzip"
+	rxresp
+	expect resp.http.Content-Encoding == "gzip"
+	gunzip
+	expect resp.body == "<1></1>"
+} -run



More information about the varnish-commit mailing list