[master] 99a40f5 Only ref the busy boc if it is not yet BOS_FINISHED

Poul-Henning Kamp phk at FreeBSD.org
Thu Jan 28 12:49:20 CET 2016


commit 99a40f5ae307d757115c15b64a413c42298bc949
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Thu Jan 21 10:55:57 2016 +0000

    Only ref the busy boc if it is not yet BOS_FINISHED

diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 6c353b6..84caa85 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -866,7 +866,7 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo)
  */
 
 static enum fetch_step
-vbf_stp_fail(struct worker *wrk, struct busyobj *bo)
+vbf_stp_fail(struct worker *wrk, const struct busyobj *bo)
 {
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 	CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c
index d75178a..3f2d9d8 100644
--- a/bin/varnishd/cache/cache_hash.c
+++ b/bin/varnishd/cache/cache_hash.c
@@ -724,10 +724,10 @@ HSH_RefBusy(const struct objcore *oc)
 	assert(oc->refcnt > 0);
 	boc = oc->boc;
 	CHECK_OBJ_ORNULL(boc, BOC_MAGIC);
-	if (boc != NULL) {
-		//CHECK_OBJ_NOTNULL(boc->busyobj, BUSYOBJ_MAGIC);
+	if (boc != NULL && boc->state < BOS_FINISHED) 
 		boc->refcount++;
-	}
+	else
+		boc = NULL;
 	Lck_Unlock(&oh->mtx);
 	return (boc);
 }
diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c
index 85cba50..9bb6071 100644
--- a/bin/varnishd/cache/cache_obj.c
+++ b/bin/varnishd/cache/cache_obj.c
@@ -217,6 +217,8 @@ ObjTrimStore(struct worker *wrk, struct objcore *oc)
 
 	CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
 
+	assert(oc->boc == NULL || oc->boc->state < BOS_FINISHED);
+
 	if (om->objtrimstore != NULL)
 		om->objtrimstore(wrk, oc);
 	return;
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 19f3797..115473a 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -198,35 +198,20 @@ cnt_deliver(struct worker *wrk, struct req *req)
 
 	/* Grab a ref to the bo if there is one, and hand it down */
 	boc = HSH_RefBusy(req->objcore);
-	if (boc != NULL) {
-		if (req->esi_level == 0 && boc->state == BOS_FINISHED) {
-			HSH_DerefBusy(wrk, req->objcore);
-			boc = NULL;
-		} else if (!boc->busyobj->do_stream) {
-			/* XXX These should go away */
-			xxxassert(boc->state >= BOS_STREAM);
-			xxxassert(boc->state >= BOS_FINISHED);
-			HSH_DerefBusy(wrk, req->objcore);
-			boc = NULL;
-		}
-	}
 
 	cnt_vdp(req, boc);
 
-	/* pass+streaming, abandon fetch in case delivery terminated early */
-	if (boc != NULL && req->objcore->flags & OC_F_PASS) {
-		CHECK_OBJ_NOTNULL(boc->busyobj, BUSYOBJ_MAGIC);
-		boc->busyobj->abandon = 1;
-	}
-
 	VSLb_ts_req(req, "Resp", W_TIM_real(wrk));
 
 	if (http_HdrIs(req->resp, H_Connection, "close"))
 		req->doclose = SC_RESP_CLOSE;
 
 	if (req->objcore->flags & (OC_F_PRIVATE | OC_F_PASS)) {
-		if (boc != NULL)
+		if (boc != NULL) {
+			CHECK_OBJ_NOTNULL(boc->busyobj, BUSYOBJ_MAGIC);
+			boc->busyobj->abandon = 1;
 			ObjWaitState(boc, BOS_FINISHED);
+		}
 		ObjSlim(wrk, req->objcore);
 	}
 



More information about the varnish-commit mailing list