[master] eef78be Don't steal the req's ref on the busyobj

Poul-Henning Kamp phk at varnish-cache.org
Wed May 22 22:56:10 CEST 2013


commit eef78bea43d2e234faf8244b8c1602fbc87c62f6
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Wed May 22 20:55:57 2013 +0000

    Don't steal the req's ref on the busyobj

diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 66a7c72..4bf15de 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -990,12 +990,12 @@ VBF_Fetch(struct worker *wrk, struct req *req)
 
 	FetchBody(wrk, bo);
 
+	assert(bo->refcount == 1);
+
 	if (req->obj->objcore->objhead != NULL)
 		HSH_Ref(req->obj->objcore);
 
-	if (bo->state == BOS_FINISHED) {
-		VBO_DerefBusyObj(wrk, &req->busyobj);
-	} else if (bo->state == BOS_FAILED) {
+	if (bo->state == BOS_FAILED) {
 		/* handle early failures */
 		(void)HSH_Deref(&wrk->stats, NULL, &req->obj);
 		return (-1);
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index e789ffe..6f4e49b 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -357,12 +357,15 @@ cnt_fetch(struct worker *wrk, struct req *req)
 	CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
 
 	i = VBF_Fetch(wrk, req);
+	AN(req->busyobj);
+	assert(req->busyobj->refcount > 0);
 	if (i < 0) {
 		VBO_DerefBusyObj(wrk, &req->busyobj);
 		req->err_code = 503;
 		req->req_step = R_STP_ERROR;
 	} else {
 		AZ(i);
+		VBO_DerefBusyObj(wrk, &req->busyobj);
 		assert(WRW_IsReleased(wrk));
 		req->req_step = R_STP_PREPRESP;
 	}



More information about the varnish-commit mailing list