[master] 85b8a22 Tell stevedores about oc->state changes.

Poul-Henning Kamp phk at FreeBSD.org
Tue Feb 23 14:40:42 CET 2016


commit 85b8a22dbefa95397f8c7cffb033378c9f0646bf
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Tue Feb 23 13:39:58 2016 +0000

    Tell stevedores about oc->state changes.
    
    This allows Martin to stash attributes on going into BOS_STREAM.

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 2b8691a..54e7ead 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -857,7 +857,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 *, ssize_t l);
 uint64_t ObjWaitExtend(struct worker *, struct objcore *, uint64_t l);
-void ObjSetState(const struct objcore *, enum boc_state_e next);
+void ObjSetState(struct worker *, 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 *, struct objcore *, double now);
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 5b15581..ae6621c 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->fetch_objcore, BOS_REQ_DONE);
+	ObjSetState(bo->wrk, bo->fetch_objcore, BOS_REQ_DONE);
 	return (F_STP_STARTFETCH);
 }
 
@@ -670,7 +670,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
 
 	if (bo->do_stream) {
 		HSH_Unbusy(wrk, bo->fetch_objcore);
-		ObjSetState(bo->fetch_objcore, BOS_STREAM);
+		ObjSetState(wrk, bo->fetch_objcore, BOS_STREAM);
 	}
 
 	VSLb(bo->vsl, SLT_Fetch_Body, "%u %s %s",
@@ -704,7 +704,7 @@ vbf_stp_fetch(struct worker *wrk, struct busyobj *bo)
 	   give predictable backend reuse behavior for varnishtest */
 	VDI_Finish(bo->wrk, bo);
 
-	ObjSetState(bo->fetch_objcore, BOS_FINISHED);
+	ObjSetState(wrk, bo->fetch_objcore, BOS_FINISHED);
 	VSLb_ts_busyobj(bo, "BerespBody", W_TIM_real(wrk));
 	if (bo->stale_oc != NULL)
 		HSH_Kill(bo->stale_oc);
@@ -758,7 +758,7 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo)
 
 	if (bo->do_stream) {
 		HSH_Unbusy(wrk, bo->fetch_objcore);
-		ObjSetState(bo->fetch_objcore, BOS_STREAM);
+		ObjSetState(wrk, bo->fetch_objcore, BOS_STREAM);
 	}
 
 	if (ObjIterate(wrk, bo->stale_oc, bo, vbf_objiterator))
@@ -780,7 +780,7 @@ vbf_stp_condfetch(struct worker *wrk, struct busyobj *bo)
 	   give predictable backend reuse behavior for varnishtest */
 	VDI_Finish(bo->wrk, bo);
 
-	ObjSetState(bo->fetch_objcore, BOS_FINISHED);
+	ObjSetState(wrk, bo->fetch_objcore, BOS_FINISHED);
 	VSLb_ts_busyobj(bo, "BerespBody", W_TIM_real(wrk));
 	return (F_STP_DONE);
 }
@@ -881,7 +881,7 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo)
 	VSB_delete(synth_body);
 
 	HSH_Unbusy(wrk, bo->fetch_objcore);
-	ObjSetState(bo->fetch_objcore, BOS_FINISHED);
+	ObjSetState(wrk, bo->fetch_objcore, BOS_FINISHED);
 	return (F_STP_DONE);
 }
 
@@ -903,7 +903,7 @@ vbf_stp_fail(struct worker *wrk, const struct busyobj *bo)
 		HSH_Kill(bo->fetch_objcore);
 	}
 	wrk->stats->fetch_failed++;
-	ObjSetState(bo->fetch_objcore, BOS_FAILED);
+	ObjSetState(wrk, bo->fetch_objcore, BOS_FAILED);
 	return (F_STP_DONE);
 }
 
diff --git a/bin/varnishd/cache/cache_obj.c b/bin/varnishd/cache/cache_obj.c
index cb32f97..a0d82b9 100644
--- a/bin/varnishd/cache/cache_obj.c
+++ b/bin/varnishd/cache/cache_obj.c
@@ -220,13 +220,21 @@ ObjWaitExtend(struct worker *wrk, struct objcore *oc, uint64_t l)
  */
 
 void
-ObjSetState(const struct objcore *oc, enum boc_state_e next)
+ObjSetState(struct worker *wrk, const struct objcore *oc, enum boc_state_e next)
 {
+	const struct obj_methods *om;
 
 	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
 	CHECK_OBJ_NOTNULL(oc->boc, BOC_MAGIC);
-
 	assert(next > oc->boc->state);
+
+	CHECK_OBJ_ORNULL(oc->stobj->stevedore, STEVEDORE_MAGIC);
+	if (oc->stobj->stevedore != NULL) {
+		om = oc->stobj->stevedore->methods;
+		if (om->objsetstate != NULL)
+			om->objsetstate(wrk, oc, next);
+	}
+
 	Lck_Lock(&oc->boc->mtx);
 	oc->boc->state = next;
 	AZ(pthread_cond_broadcast(&oc->boc->cond));
diff --git a/bin/varnishd/cache/cache_obj.h b/bin/varnishd/cache/cache_obj.h
index c4eea09..0b0e2ca 100644
--- a/bin/varnishd/cache/cache_obj.h
+++ b/bin/varnishd/cache/cache_obj.h
@@ -32,7 +32,8 @@
 
 typedef void objfree_f(struct worker *, struct objcore *);
 
-/* This method is only used by SML (...to get to persistent) */
+typedef void objsetstate_f(struct worker *, const struct objcore *,
+    enum boc_state_e);
 
 typedef int objiterator_f(struct worker *, struct objcore *,
     void *priv, objiterate_f *func);
@@ -59,5 +60,6 @@ struct obj_methods {
 	objgetattr_f	*objgetattr;
 	objsetattr_f	*objsetattr;
 	objtouch_f	*objtouch;
+	objsetstate_f	*objsetstate;
 };
 



More information about the varnish-commit mailing list