[4.1] c0a515b Deal with fetch failures in ved_stripgzip
PÃ¥l Hermunn Johansen
hermunn at varnish-software.com
Wed Jun 15 10:48:08 CEST 2016
commit c0a515b061f6d75db188127b7b0da74c611144ac
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 32c8b90..528704a 100644
--- a/bin/varnishd/cache/cache_esi_deliver.c
+++ b/bin/varnishd/cache/cache_esi_deliver.c
@@ -530,8 +530,14 @@ ved_stripgzip(struct req *req, struct busyobj *bo)
CAST_OBJ_NOTNULL(ecx, req->transport_priv, ECX_MAGIC);
preq = ecx->preq;
+ /* OA_GZIPBITS is not valid until BOS_FINISHED */
if (bo != NULL)
VBO_waitstate(bo, 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