[master] 38a635c Use objcore argument for setting and waiting for (b)oc state

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


commit 38a635c4b2056262385cb6edb09f611186672b86
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Thu Jan 21 20:43:14 2016 +0000

    Use objcore argument for setting and waiting for (b)oc state

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 442fe48..6f4f890 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -854,8 +854,8 @@ int ObjIterate(struct worker *, struct objcore *,
 int ObjGetSpace(struct worker *, struct objcore *, ssize_t *sz, uint8_t **ptr);
 void ObjExtend(struct worker *, struct objcore *, struct boc *, ssize_t l);
 ssize_t ObjWaitExtend(struct worker *, struct objcore *, struct boc *, ssize_t l);
-void ObjSetState(struct boc *, enum boc_state_e next);
-void ObjWaitState(struct boc *, enum boc_state_e want);
+void ObjSetState(const struct objcore *, enum boc_state_e next);
+void ObjWaitState(const struct objcore *, enum boc_state_e want);
 void ObjTrimStore(struct worker *, struct objcore *);
 void ObjTouch(struct worker *wrk, struct objcore *oc, double now);
 unsigned ObjGetXID(struct worker *, struct objcore *);
diff --git a/bin/varnishd/cache/cache_esi_deliver.c b/bin/varnishd/cache/cache_esi_deliver.c
index a9a8348..703109b 100644
--- a/bin/varnishd/cache/cache_esi_deliver.c
+++ b/bin/varnishd/cache/cache_esi_deliver.c
@@ -668,7 +668,7 @@ ved_objiterate(void *priv, int flush, const void *ptr, ssize_t len)
 }
 
 static void
-ved_stripgzip(struct req *req, struct boc *boc)
+ved_stripgzip(struct req *req, const struct boc *boc)
 {
 	ssize_t l;
 	char *p;
@@ -689,7 +689,7 @@ ved_stripgzip(struct req *req, struct boc *boc)
 
 	/* OA_GZIPBITS is not valid until BOS_FINISHED */
 	if (boc != NULL)
-		ObjWaitState(boc, BOS_FINISHED);
+		ObjWaitState(req->objcore, BOS_FINISHED);
 
 	AN(ObjCheckFlag(req->wrk, req->objcore, OF_GZIPED));
 
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 8c49ee4..df86a5a 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -202,7 +202,7 @@ vbf_stp_mkbereq(const struct worker *wrk, struct busyobj *bo)
 	bo->ws_bo = WS_Snapshot(bo->ws);
 	HTTP_Copy(bo->bereq, bo->bereq0);
 
-	ObjSetState(bo->boc, BOS_REQ_DONE);
+	ObjSetState(bo->fetch_objcore, BOS_REQ_DONE);
 	return (F_STP_STARTFETCH);
 }
 
@@ -648,7 +648,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
 
 	if (bo->do_stream) {
 		HSH_Unbusy(wrk, bo->fetch_objcore);
-		ObjSetState(bo->boc, BOS_STREAM);
+		ObjSetState(bo->fetch_objcore, BOS_STREAM);
 	}
 
 	VSLb(bo->vsl, SLT_Fetch_Body, "%u %s %s",
@@ -682,7 +682,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
 	   give predictable backend reuse behavior for varnishtest */
 	VDI_Finish(bo->wrk, bo);
 
-	ObjSetState(bo->boc, BOS_FINISHED);
+	ObjSetState(bo->fetch_objcore, BOS_FINISHED);
 	VSLb_ts_busyobj(bo, "BerespBody", W_TIM_real(wrk));
 	if (bo->stale_oc != NULL)
 		EXP_Rearm(bo->stale_oc, bo->stale_oc->exp.t_origin, 0, 0, 0);
@@ -736,7 +736,7 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo)
 
 	if (bo->do_stream) {
 		HSH_Unbusy(wrk, bo->fetch_objcore);
-		ObjSetState(bo->boc, BOS_STREAM);
+		ObjSetState(bo->fetch_objcore, BOS_STREAM);
 	}
 
 	if (ObjIterate(wrk, bo->stale_oc, bo, vbf_objiterator))
@@ -758,7 +758,7 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo)
 	   give predictable backend reuse behavior for varnishtest */
 	VDI_Finish(bo->wrk, bo);
 
-	ObjSetState(bo->boc, BOS_FINISHED);
+	ObjSetState(bo->fetch_objcore, BOS_FINISHED);
 	VSLb_ts_busyobj(bo, "BerespBody", W_TIM_real(wrk));
 	return (F_STP_DONE);
 }
@@ -858,7 +858,7 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo)
 	VSB_delete(synth_body);
 
 	HSH_Unbusy(wrk, bo->fetch_objcore);
-	ObjSetState(bo->boc, BOS_FINISHED);
+	ObjSetState(bo->fetch_objcore, BOS_FINISHED);
 	return (F_STP_DONE);
 }
 
@@ -881,7 +881,7 @@ vbf_stp_fail(struct worker *wrk, const struct busyobj *bo)
 		    bo->fetch_objcore->exp.t_origin, 0, 0, 0);
 	}
 	wrk->stats->fetch_failed++;
-	ObjSetState(bo->boc, BOS_FAILED);
+	ObjSetState(bo->fetch_objcore, BOS_FAILED);
 	return (F_STP_DONE);
 }
 
@@ -1034,10 +1034,10 @@ VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc,
 	} else {
 		bo = NULL; /* ref transferred to fetch thread */
 		if (mode == VBF_BACKGROUND) {
-			ObjWaitState(boc, BOS_REQ_DONE);
+			ObjWaitState(oc, BOS_REQ_DONE);
 		} else {
-			ObjWaitState(boc, BOS_STREAM);
-			if (boc->state == BOS_FAILED) {
+			ObjWaitState(oc, BOS_STREAM);
+			if (oc->boc->state == BOS_FAILED) {
 				AN((oc->flags & OC_F_FAILED));
 			} else {
 				AZ(oc->flags & OC_F_BUSY);
diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c
index 018e280..986254f 100644
--- a/bin/varnishd/cache/cache_obj.c
+++ b/bin/varnishd/cache/cache_obj.c
@@ -155,35 +155,36 @@ ObjWaitExtend(struct worker *wrk, struct objcore *oc, struct boc *boc,
  */
 
 void
-ObjSetState(struct boc *boc, enum boc_state_e next)
+ObjSetState(const struct objcore *oc, enum boc_state_e next)
 {
 
-	CHECK_OBJ_NOTNULL(boc, BOC_MAGIC);
+	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
+	CHECK_OBJ_NOTNULL(oc->boc, BOC_MAGIC);
 
-	// assert(bo->do_stream || next != BOS_STREAM);
-	assert(next > boc->state);
-	Lck_Lock(&boc->mtx);
-	boc->state = next;
-	AZ(pthread_cond_broadcast(&boc->cond));
-	Lck_Unlock(&boc->mtx);
+	assert(next > oc->boc->state);
+	Lck_Lock(&oc->boc->mtx);
+	oc->boc->state = next;
+	AZ(pthread_cond_broadcast(&oc->boc->cond));
+	Lck_Unlock(&oc->boc->mtx);
 }
 
 /*====================================================================
  */
 
 void
-ObjWaitState(struct boc *boc, enum boc_state_e want)
+ObjWaitState(const struct objcore *oc, enum boc_state_e want)
 {
 
-	CHECK_OBJ_NOTNULL(boc, BOC_MAGIC);
+	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
+	CHECK_OBJ_NOTNULL(oc->boc, BOC_MAGIC);
 
-	Lck_Lock(&boc->mtx);
+	Lck_Lock(&oc->boc->mtx);
 	while (1) {
-		if (boc->state >= want)
+		if (oc->boc->state >= want)
 			break;
-		(void)Lck_CondWait(&boc->cond, &boc->mtx, 0);
+		(void)Lck_CondWait(&oc->boc->cond, &oc->boc->mtx, 0);
 	}
-	Lck_Unlock(&boc->mtx);
+	Lck_Unlock(&oc->boc->mtx);
 }
 
 /*====================================================================
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index b2ee4bb..8686634 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -209,7 +209,7 @@ cnt_deliver(struct worker *wrk, struct req *req)
 	if (req->objcore->flags & (OC_F_PRIVATE | OC_F_PASS)) {
 		if (boc != NULL) {
 			HSH_Abandon(req->objcore);
-			ObjWaitState(boc, BOS_FINISHED);
+			ObjWaitState(req->objcore, BOS_FINISHED);
 		}
 		ObjSlim(wrk, req->objcore);
 	}



More information about the varnish-commit mailing list