Commit 85b8a22d authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Tell stevedores about oc->state changes.

This allows Martin to stash attributes on going into BOS_STREAM.
parent e964656b
......@@ -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);
......
......@@ -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);
}
......
......@@ -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));
......
......@@ -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;
};
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment