[4.0] 4067f50 Don't put objcores on the ban list until they go non-BUSY.

Poul-Henning Kamp phk at FreeBSD.org
Thu Mar 13 10:24:22 CET 2014


commit 4067f504827b349ee61d481b5218b1e1b09afed1
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Wed Jan 29 11:18:33 2014 +0000

    Don't put objcores on the ban list until they go non-BUSY.
    
    Fixes	#1419

diff --git a/bin/varnishd/cache/cache_ban.c b/bin/varnishd/cache/cache_ban.c
index 477aa6a..1c6b0c8 100644
--- a/bin/varnishd/cache/cache_ban.c
+++ b/bin/varnishd/cache/cache_ban.c
@@ -1030,6 +1030,7 @@ ban_lurker_getfirst(struct vsl_log *vsl, struct ban *bt)
 				 * We got the lock, and the oc is not being
 				 * dismantled under our feet, run with it...
 				 */
+				AZ(oc->flags & OC_F_BUSY);
 				oc->refcnt += 1;
 				VTAILQ_REMOVE(&bt->objcore, oc, ban_list);
 				VTAILQ_INSERT_TAIL(&bt->objcore, oc, ban_list);
diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c
index 5d89c77..eb69164 100644
--- a/bin/varnishd/cache/cache_hash.c
+++ b/bin/varnishd/cache/cache_hash.c
@@ -667,10 +667,6 @@ HSH_Unbusy(struct dstat *ds, struct objcore *oc)
 	CHECK_OBJ(oh, OBJHEAD_MAGIC);
 
 	AN(oc->flags & OC_F_BUSY);
-	if (oc->flags & OC_F_PRIVATE)
-		AZ(oc->ban);
-	else
-		AN(oc->ban);
 	assert(oh->refcnt > 0);
 
 	/* XXX: pretouch neighbors on oh->objcs to prevent page-on under mtx */
@@ -683,6 +679,8 @@ HSH_Unbusy(struct dstat *ds, struct objcore *oc)
 	if (oh->waitinglist != NULL)
 		hsh_rush(ds, oh);
 	Lck_Unlock(&oh->mtx);
+	if (!(oc->flags & OC_F_PRIVATE))
+		BAN_NewObjCore(oc);
 }
 
 /*---------------------------------------------------------------------
diff --git a/bin/varnishd/storage/stevedore.c b/bin/varnishd/storage/stevedore.c
index e1cc3c8..c2788a9 100644
--- a/bin/varnishd/storage/stevedore.c
+++ b/bin/varnishd/storage/stevedore.c
@@ -291,8 +291,6 @@ STV_MkObject(struct stevedore *stv, struct busyobj *bo,
 	bo->stats->n_object++;
 
 	o->objcore = bo->fetch_objcore;
-	if (!(o->objcore->flags & OC_F_PRIVATE))
-		BAN_NewObjCore(o->objcore);
 
 	o->objcore->methods = &default_oc_methods;
 	o->objcore->priv = o;
diff --git a/bin/varnishtest/tests/r01419.vtc b/bin/varnishtest/tests/r01419.vtc
new file mode 100644
index 0000000..5165c63
--- /dev/null
+++ b/bin/varnishtest/tests/r01419.vtc
@@ -0,0 +1,43 @@
+varnishtest "Make sure banlurker skips busy objects"
+
+server s1 {
+	rxreq
+	send "HTTP/1.0 200 Ok\r\n"
+	sema r1 sync 2
+	send "Foobar: blaf\r\n"
+	send "Content-Length: 10\r\n"
+	send "\r\n\r\n"
+	send "abcde"
+	sema r2 sync 2
+	send "abcdefghij"
+} -start
+
+varnish v1 -vcl+backend {
+	sub vcl_backend_response {
+		set beresp.do_stream = false;
+	}
+} -start
+
+varnish v1 -cliok {param.set debug +lurker}
+varnish v1 -cliok {param.set ban_lurker_age 1}
+varnish v1 -cliok {ban.list}
+
+client c1 {
+	txreq
+	rxresp
+	expect resp.status == 200
+	expect resp.http.foobar == blaf
+} -start
+
+sema r1 sync 2
+varnish v1 -cliok {ban.list}
+
+varnish v1 -cliok {ban obj.http.goo == bar}
+varnish v1 -cliok {ban.list}
+delay 2
+varnish v1 -cliok {ban.list}
+
+
+sema r2 sync 2
+
+client c1 -wait



More information about the varnish-commit mailing list