Commit de6e9b67 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Reduce strength arguments from busyobj to boc

parent 9f8dba34
......@@ -680,11 +680,10 @@ double BAN_Time(const struct ban *ban);
/* cache_busyobj.c */
struct busyobj *VBO_GetBusyObj(struct worker *, const struct req *);
void VBO_DerefBusyObj(struct worker *wrk, struct busyobj **busyobj);
void VBO_extend(struct worker *, struct objcore *, struct busyobj *, ssize_t);
ssize_t VBO_waitlen(struct worker *, struct objcore *, struct busyobj *,
ssize_t l);
void VBO_setstate(struct busyobj *bo, enum busyobj_state_e next);
void VBO_waitstate(struct busyobj *bo, enum busyobj_state_e want);
void VBO_extend(struct worker *, struct objcore *, struct boc *, ssize_t);
ssize_t VBO_waitlen(struct worker *, struct objcore *, struct boc *, ssize_t l);
void VBO_setstate(struct boc *, enum busyobj_state_e next);
void VBO_waitstate(struct boc *, enum busyobj_state_e want);
/* cache_cli.c [CLI] */
extern pthread_t cli_thread;
......
......@@ -227,64 +227,69 @@ VBO_DerefBusyObj(struct worker *wrk, struct busyobj **pbo)
}
void
VBO_extend(struct worker *wrk, struct objcore *oc, struct busyobj *bo,
VBO_extend(struct worker *wrk, struct objcore *oc, struct boc *boc,
ssize_t l)
{
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
CHECK_OBJ_NOTNULL(boc, BOC_MAGIC);
if (l == 0)
return;
assert(l > 0);
Lck_Lock(&bo->boc->mtx);
Lck_Lock(&boc->mtx);
ObjExtend(wrk, oc, l);
AZ(pthread_cond_broadcast(&bo->boc->cond));
Lck_Unlock(&bo->boc->mtx);
AZ(pthread_cond_broadcast(&boc->cond));
Lck_Unlock(&boc->mtx);
}
ssize_t
VBO_waitlen(struct worker *wrk, struct objcore *oc, struct busyobj *bo,
VBO_waitlen(struct worker *wrk, struct objcore *oc, struct boc *boc,
ssize_t l)
{
ssize_t rv;
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
xxxassert(bo->fetch_objcore == oc);
Lck_Lock(&bo->boc->mtx);
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
CHECK_OBJ_NOTNULL(boc, BOC_MAGIC);
Lck_Lock(&boc->mtx);
rv = ObjGetLen(wrk, oc);
while (1) {
assert(l <= rv || bo->boc->state == BOS_FAILED);
if (rv > l || bo->boc->state >= BOS_FINISHED)
assert(l <= rv || boc->state == BOS_FAILED);
if (rv > l || boc->state >= BOS_FINISHED)
break;
(void)Lck_CondWait(&bo->boc->cond, &bo->boc->mtx, 0);
(void)Lck_CondWait(&boc->cond, &boc->mtx, 0);
rv = ObjGetLen(wrk, oc);
}
Lck_Unlock(&bo->boc->mtx);
Lck_Unlock(&boc->mtx);
return (rv);
}
void
VBO_setstate(struct busyobj *bo, enum busyobj_state_e next)
VBO_setstate(struct boc *boc, enum busyobj_state_e next)
{
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
assert(bo->do_stream || next != BOS_STREAM);
assert(next > bo->boc->state);
Lck_Lock(&bo->boc->mtx);
bo->boc->state = next;
AZ(pthread_cond_broadcast(&bo->boc->cond));
Lck_Unlock(&bo->boc->mtx);
CHECK_OBJ_NOTNULL(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);
}
void
VBO_waitstate(struct busyobj *bo, enum busyobj_state_e want)
VBO_waitstate(struct boc *boc, enum busyobj_state_e want)
{
Lck_Lock(&bo->boc->mtx);
CHECK_OBJ_NOTNULL(boc, BOC_MAGIC);
Lck_Lock(&boc->mtx);
while (1) {
if (bo->boc->state >= want)
if (boc->state >= want)
break;
(void)Lck_CondWait(&bo->boc->cond, &bo->boc->mtx, 0);
(void)Lck_CondWait(&boc->cond, &boc->mtx, 0);
}
Lck_Unlock(&bo->boc->mtx);
Lck_Unlock(&boc->mtx);
}
......@@ -689,7 +689,7 @@ ved_stripgzip(struct req *req, struct busyobj *bo)
/* XXX: Is this really required ? */
if (bo != NULL)
VBO_waitstate(bo, BOS_FINISHED);
VBO_waitstate(bo->boc, BOS_FINISHED);
AN(ObjCheckFlag(req->wrk, req->objcore, OF_GZIPED));
......
......@@ -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);
VBO_setstate(bo, BOS_REQ_DONE);
VBO_setstate(bo->boc, 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);
VBO_setstate(bo, BOS_STREAM);
VBO_setstate(bo->boc, 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);
VBO_setstate(bo, BOS_FINISHED);
VBO_setstate(bo->boc, 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);
VBO_setstate(bo, BOS_STREAM);
VBO_setstate(bo->boc, 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);
VBO_setstate(bo, BOS_FINISHED);
VBO_setstate(bo->boc, 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);
VBO_setstate(bo, BOS_FINISHED);
VBO_setstate(bo->boc, BOS_FINISHED);
return (F_STP_DONE);
}
......@@ -881,7 +881,7 @@ vbf_stp_fail(struct worker *wrk, struct busyobj *bo)
bo->fetch_objcore->exp.t_origin, 0, 0, 0);
}
wrk->stats->fetch_failed++;
VBO_setstate(bo, BOS_FAILED);
VBO_setstate(bo->boc, BOS_FAILED);
return (F_STP_DONE);
}
......@@ -1031,9 +1031,9 @@ VBF_Fetch(struct worker *wrk, struct req *req, struct objcore *oc,
} else {
bo_fetch = NULL; /* ref transferred to fetch thread */
if (mode == VBF_BACKGROUND) {
VBO_waitstate(bo, BOS_REQ_DONE);
VBO_waitstate(bo->boc, BOS_REQ_DONE);
} else {
VBO_waitstate(bo, BOS_STREAM);
VBO_waitstate(bo->boc, BOS_STREAM);
if (bo->boc->state == BOS_FAILED) {
AN((oc->flags & OC_F_FAILED));
} else {
......
......@@ -98,7 +98,7 @@ VFP_Extend(const struct vfp_ctx *vc, ssize_t sz)
{
CHECK_OBJ_NOTNULL(vc, VFP_CTX_MAGIC);
VBO_extend(vc->wrk, vc->oc, vc->bo, sz);
VBO_extend(vc->wrk, vc->oc, vc->bo->boc, sz);
}
/**********************************************************************
......
......@@ -202,7 +202,7 @@ cnt_deliver(struct worker *wrk, struct req *req)
if (req->esi_level == 0 && bo->boc->state == BOS_FINISHED) {
VBO_DerefBusyObj(wrk, &bo);
} else if (!bo->do_stream) {
VBO_waitstate(bo, BOS_FINISHED);
VBO_waitstate(bo->boc, BOS_FINISHED);
VBO_DerefBusyObj(wrk, &bo);
}
}
......@@ -216,7 +216,7 @@ cnt_deliver(struct worker *wrk, struct req *req)
if (req->objcore->flags & (OC_F_PRIVATE | OC_F_PASS)) {
if (bo != NULL)
VBO_waitstate(bo, BOS_FINISHED);
VBO_waitstate(bo->boc, BOS_FINISHED);
ObjSlim(wrk, req->objcore);
}
......
......@@ -257,7 +257,7 @@ sml_iterator(struct worker *wrk, struct objcore *oc,
while (1) {
ol = len;
nl = VBO_waitlen(wrk, oc, bo, ol);
nl = VBO_waitlen(wrk, oc, bo->boc, ol);
if (bo->boc->state == BOS_FAILED) {
ret = -1;
break;
......
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