[PATCH] Propagate gzip crc checksum up the ESI stack

Martin Blix Grydeland martin at varnish-software.com
Wed Sep 9 17:31:34 CEST 2015


When tearing down the ESI data structures, propagate the gzip crc
checksum up the stack.

Fixes: #1781
---
 bin/varnishd/cache/cache_esi_deliver.c |  8 +++++++-
 bin/varnishtest/tests/r01781.vtc       | 27 +++++++++++++++++++++++++++
 2 files changed, 34 insertions(+), 1 deletion(-)
 create mode 100644 bin/varnishtest/tests/r01781.vtc

diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c
index ff30ae3..1d617b8 100644
--- a/bin/varnishd/cache/cache_esi_deliver.c
+++ b/bin/varnishd/cache/cache_esi_deliver.c
@@ -228,7 +228,7 @@ VDP_ESI(struct req *req, enum vdp_action act, void **priv,
 	uint32_t icrc = 0;
 	uint8_t tailbuf[8 + 5];
 	const uint8_t *pp;
-	struct ecx *ecx;
+	struct ecx *ecx, *pecx;
 	int retval = 0;
 
 	if (act == VDP_INIT) {
@@ -241,6 +241,12 @@ VDP_ESI(struct req *req, enum vdp_action act, void **priv,
 	}
 	CAST_OBJ_NOTNULL(ecx, *priv, ECX_MAGIC);
 	if (act == VDP_FINI) {
+		if (req->transport->deliver == VED_Deliver) {
+			CAST_OBJ_NOTNULL(pecx, req->transport_priv, ECX_MAGIC);
+			pecx->crc = crc32_combine(pecx->crc,
+			    ecx->crc, ecx->l_crc);
+			pecx->l_crc += ecx->l_crc;
+		}
 		FREE_OBJ(ecx);
 		*priv = NULL;
 		return (0);
diff --git a/bin/varnishtest/tests/r01781.vtc b/bin/varnishtest/tests/r01781.vtc
new file mode 100644
index 0000000..5b796d8
--- /dev/null
+++ b/bin/varnishtest/tests/r01781.vtc
@@ -0,0 +1,27 @@
+varnishtest "#1781 gzip checksum with multilevel esi"
+
+server s1 {
+	rxreq
+	txresp -body {<esi:include src="/1"/>Baz}
+
+	rxreq
+	txresp -body {<esi:include src="/2"/>Bar}
+
+	rxreq
+	txresp -body {Foo}
+} -start
+
+varnish v1 -vcl+backend {
+	sub vcl_backend_response {
+		set beresp.do_gzip = true;
+		set beresp.do_esi = true;
+	}
+} -start
+
+client c1 {
+	txreq -hdr "Accept-Encoding: gzip"
+	rxresp
+	expect resp.http.content-encoding == "gzip"
+	gunzip
+	expect resp.body == "FooBarBaz"
+} -run
-- 
2.1.4




More information about the varnish-dev mailing list