[master] f82b5f150 Don't ignore OA_GZIPBITS if there is a boc

Dridi Boukelmoune dridi.boukelmoune at gmail.com
Mon Jan 13 17:48:06 UTC 2020


commit f82b5f150f2a9aa92ac38665d90082cc51aeb2d8
Author: Dridi Boukelmoune <dridi.boukelmoune at gmail.com>
Date:   Fri Jan 10 20:17:44 2020 +0100

    Don't ignore OA_GZIPBITS if there is a boc
    
    Under load, client c4 from g00005.vtc may fail with a 200 response
    instead of the expected 206 partial response.
    
    There is a window during which we might still see a boc, but because
    c4 sets beresp.do_stream to false, the fetch has to be over. To close
    this race we can instead reference the boc as suggested in #2904 and
    keep track of the boc state.

diff --git a/bin/varnishd/cache/cache_gzip.c b/bin/varnishd/cache/cache_gzip.c
index 758c990cf..694ee43d4 100644
--- a/bin/varnishd/cache/cache_gzip.c
+++ b/bin/varnishd/cache/cache_gzip.c
@@ -42,6 +42,7 @@
 
 #include "cache_varnishd.h"
 #include "cache_filter.h"
+#include "cache_objhead.h"
 #include "cache_vgz.h"
 #include "vend.h"
 
@@ -288,6 +289,8 @@ static int v_matchproto_(vdp_init_f)
 vdp_gunzip_init(struct req *req, void **priv)
 {
 	struct vgz *vg;
+	struct boc *boc;
+	enum boc_state_e bos;
 	const char *p;
 	ssize_t dl;
 	uint64_t u;
@@ -309,8 +312,15 @@ vdp_gunzip_init(struct req *req, void **priv)
 
 	req->resp_len = -1;
 
+	boc = HSH_RefBoc(req->objcore);
+	if (boc != NULL) {
+		bos = boc->state;
+		HSH_DerefBoc(req->wrk, req->objcore);
+	} else
+		bos = BOS_FINISHED;
+
 	/* OA_GZIPBITS is not stable yet */
-	if (req->objcore->boc)
+	if (bos < BOS_FINISHED)
 		return (0);
 
 	p = ObjGetAttr(req->wrk, req->objcore, OA_GZIPBITS, &dl);
diff --git a/bin/varnishtest/tests/g00005.vtc b/bin/varnishtest/tests/g00005.vtc
index 24b3b6071..74b21de5b 100644
--- a/bin/varnishtest/tests/g00005.vtc
+++ b/bin/varnishtest/tests/g00005.vtc
@@ -35,7 +35,7 @@ client c1 {
 
 varnish v1 -vsl_catchup
 
-client c1 {
+client c2 {
 	txreq -hdr "Accept-encoding: gzip;q=0.1"
 	rxresp
 	expect resp.http.content-encoding == "gzip"
@@ -49,7 +49,7 @@ varnish v1 -vsl_catchup
 # is completed before we attempt the range request
 delay 2
 
-client c1 {
+client c3 {
 	txreq -hdr "Range: bytes=3-5"
 	rxresp
 	expect resp.status == 206
@@ -60,7 +60,7 @@ client c1 {
 
 varnish v1 -vsl_catchup
 
-client c1 {
+client c4 {
 	txreq -url "/nostreamcachemiss" -hdr "Range: bytes=3-5"
 	rxresp
 	expect resp.status == 206
@@ -71,7 +71,7 @@ client c1 {
 
 varnish v1 -vsl_catchup
 
-client c1 {
+client c5 {
 	# simple cache miss, no stream, no gunzip
 	txreq -url "/nostream2" -hdr "Range: bytes=3-5" -hdr "Accept-Encoding: gzip"
 	rxresp


More information about the varnish-commit mailing list