[master] 3dc48ce Continuously update our total object size estimate when cond-fetching a still-being-streamed object.

Poul-Henning Kamp phk at FreeBSD.org
Tue Dec 16 10:55:55 CET 2014


commit 3dc48cec578ab1e9f99706b3508973f6b676b8e4
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Dec 16 09:55:19 2014 +0000

    Continuously update our total object size estimate when cond-fetching
    a still-being-streamed object.
    
    Fixes	#1646

diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index c44992b..f74a5c0 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -665,7 +665,6 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo)
 	void *sp;
 	ssize_t sl, al, l;
 	uint8_t *ptr;
-	uint64_t ol;
 	enum objiter_status ois;
 
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
@@ -686,12 +685,12 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo)
 	}
 
 	al = 0;
-	ol = ObjGetLen(bo->wrk, bo->ims_oc);
 	oi = ObjIterBegin(wrk, bo->ims_oc);
 	do {
 		ois = ObjIter(bo->ims_oc, oi, &sp, &sl);
 		while (sl > 0) {
-			l = ol - al;
+			l = ObjGetLen(bo->wrk, bo->ims_oc) - al;
+			assert(l > 0);
 			if (VFP_GetStorage(bo->vfc, &l, &ptr) != VFP_OK)
 				break;
 			if (sl < l)
@@ -710,7 +709,6 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo)
 	if (!bo->do_stream)
 		HSH_Unbusy(wrk, bo->fetch_objcore);
 
-	assert(al == ol);
 	assert(ObjGetLen(bo->wrk, bo->fetch_objcore) == al);
 	EXP_Rearm(bo->ims_oc, bo->ims_oc->exp.t_origin, 0, 0, 0);
 
diff --git a/bin/varnishtest/tests/r01646.vtc b/bin/varnishtest/tests/r01646.vtc
new file mode 100644
index 0000000..951350e
--- /dev/null
+++ b/bin/varnishtest/tests/r01646.vtc
@@ -0,0 +1,54 @@
+varnishtest "cond/stream race ?"
+
+server s1 {
+	rxreq
+	txresp -nolen -hdr "Transfer-Encoding: chunked" -hdr "Etag: foo"
+	chunkedlen 32
+	sema r1 sync 3
+	chunkedlen 32
+	sema r2 sync 2
+	chunkedlen 32
+	chunkedlen 0
+} -start
+
+server s2 {
+	rxreq
+	expect req.http.if-none-match == "foo"
+	txresp -status 304
+} -start
+
+varnish v1 -vcl+backend {
+	sub vcl_backend_fetch {
+		if (bereq.http.foo == "s2") {
+			set bereq.backend = s2;
+		}
+	}
+	sub vcl_backend_response {
+		set beresp.ttl = 1s;
+		set beresp.grace = 0s;
+		set beresp.keep = 30s;
+	}
+} -start
+
+varnish v1 -cliok "param.set debug +syncvsl"
+
+client c1 {
+	txreq
+	rxresphdrs
+	sema r1 sync 3
+	rxrespbody
+	expect resp.bodylen == 96
+} -start
+
+client c2 {
+	sema r1 sync 3
+	delay 2
+	txreq -hdr "foo: s2"
+	rxresphdrs
+	sema r2 sync 2
+	rxrespbody
+	expect resp.bodylen == 96
+} -start
+
+client c1 -wait
+client c2 -wait



More information about the varnish-commit mailing list