Commit 98791be3 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

When we ref/deref busy oc's, act on struct boc instead of busyobj

parent 5efe0cda
......@@ -706,11 +706,12 @@ HSH_Ref(struct objcore *oc)
* Gain a reference on the busyobj, if the objcore has one
*/
struct busyobj *
struct boc *
HSH_RefBusy(const struct objcore *oc)
{
struct objhead *oh;
struct busyobj *bo;
struct boc *boc = NULL;
CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
oh = oc->objhead;
......@@ -719,10 +720,30 @@ HSH_RefBusy(const struct objcore *oc)
assert(oc->refcnt > 0);
bo = oc->busyobj;
CHECK_OBJ_ORNULL(bo, BUSYOBJ_MAGIC);
if (bo != NULL)
bo->boc->refcount++;
if (bo != NULL) {
CHECK_OBJ_NOTNULL(bo->boc, BOC_MAGIC);
boc = bo->boc;
assert(boc->busyobj == bo);
boc->refcount++;
}
Lck_Unlock(&oh->mtx);
return (bo);
return (boc);
}
void
HSH_DerefBusy(struct worker *wrk, struct boc **pp)
{
struct boc *boc;
struct busyobj *bo;
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
AN(pp);
boc = *pp;
*pp = NULL;
CHECK_OBJ_NOTNULL(boc, BOC_MAGIC);
CHECK_OBJ_NOTNULL(boc->busyobj, BUSYOBJ_MAGIC);
bo = boc->busyobj;
VBO_DerefBusyObj(wrk, &bo);
}
/*--------------------------------------------------------------------
......
......@@ -115,7 +115,7 @@ cnt_vdp(struct req *req, struct boc *boc)
static enum req_fsm_nxt
cnt_deliver(struct worker *wrk, struct req *req)
{
struct busyobj *bo;
struct boc *boc;
CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
......@@ -197,21 +197,23 @@ cnt_deliver(struct worker *wrk, struct req *req)
http_PutResponse(req->resp, "HTTP/1.1", 304, NULL);
/* Grab a ref to the bo if there is one, and hand it down */
bo = HSH_RefBusy(req->objcore);
if (bo != NULL) {
if (req->esi_level == 0 && bo->boc->state == BOS_FINISHED) {
VBO_DerefBusyObj(wrk, &bo);
} else if (!bo->do_stream) {
ObjWaitState(bo->boc, BOS_FINISHED);
VBO_DerefBusyObj(wrk, &bo);
boc = HSH_RefBusy(req->objcore);
if (boc != NULL) {
if (req->esi_level == 0 && boc->state == BOS_FINISHED) {
HSH_DerefBusy(wrk, &boc);
} else if (!boc->busyobj->do_stream) {
ObjWaitState(boc, BOS_FINISHED);
HSH_DerefBusy(wrk, &boc);
}
}
cnt_vdp(req, bo == NULL ? NULL : bo->boc);
cnt_vdp(req, boc);
/* pass+streaming, abandon fetch in case delivery terminated early */
if (bo != NULL && req->objcore->flags & OC_F_PASS)
bo->abandon = 1;
if (boc != NULL && req->objcore->flags & OC_F_PASS) {
CHECK_OBJ_NOTNULL(boc->busyobj, BUSYOBJ_MAGIC);
boc->busyobj->abandon = 1;
}
VSLb_ts_req(req, "Resp", W_TIM_real(wrk));
......@@ -219,13 +221,13 @@ cnt_deliver(struct worker *wrk, struct req *req)
req->doclose = SC_RESP_CLOSE;
if (req->objcore->flags & (OC_F_PRIVATE | OC_F_PASS)) {
if (bo != NULL)
ObjWaitState(bo->boc, BOS_FINISHED);
if (boc != NULL)
ObjWaitState(boc, BOS_FINISHED);
ObjSlim(wrk, req->objcore);
}
if (bo != NULL)
VBO_DerefBusyObj(wrk, &bo);
if (boc != NULL)
HSH_DerefBusy(wrk, &boc);
(void)HSH_DerefObjCore(wrk, &req->objcore);
http_Teardown(req->resp);
......
......@@ -72,7 +72,8 @@ void HSH_Insert(struct worker *, const void *hash, struct objcore *);
void HSH_Purge(struct worker *, struct objhead *, double ttl, double grace,
double keep);
void HSH_config(const char *h_arg);
struct busyobj *HSH_RefBusy(const struct objcore *oc);
struct boc *HSH_RefBusy(const struct objcore *);
void HSH_DerefBusy(struct worker *wrk, struct boc **);
struct objcore *HSH_Private(struct worker *wrk);
#ifdef VARNISH_CACHE_CHILD
......
......@@ -227,7 +227,7 @@ static int __match_proto__(objiterate_f)
sml_iterator(struct worker *wrk, struct objcore *oc,
void *priv, objiterate_f *func)
{
struct busyobj *bo;
struct boc *boc;
struct object *obj;
struct storage *st;
struct storage *checkpoint = NULL;
......@@ -243,9 +243,9 @@ sml_iterator(struct worker *wrk, struct objcore *oc,
obj = sml_getobj(wrk, oc);
CHECK_OBJ_NOTNULL(obj, OBJECT_MAGIC);
bo = HSH_RefBusy(oc);
boc = HSH_RefBusy(oc);
if (bo == NULL) {
if (boc == NULL) {
VTAILQ_FOREACH(st, &obj->list, list)
if (func(priv, 0, st->ptr, st->len))
return (-1);
......@@ -257,17 +257,17 @@ sml_iterator(struct worker *wrk, struct objcore *oc,
while (1) {
ol = len;
nl = ObjWaitExtend(wrk, oc, bo->boc, ol);
if (bo->boc->state == BOS_FAILED) {
nl = ObjWaitExtend(wrk, oc, boc, ol);
if (boc->state == BOS_FAILED) {
ret = -1;
break;
}
if (nl == ol) {
if (bo->boc->state == BOS_FINISHED)
if (boc->state == BOS_FINISHED)
break;
continue;
}
Lck_Lock(&bo->boc->mtx);
Lck_Lock(&boc->mtx);
AZ(VTAILQ_EMPTY(&obj->list));
if (checkpoint == NULL) {
st = VTAILQ_FIRST(&obj->list);
......@@ -300,14 +300,14 @@ sml_iterator(struct worker *wrk, struct objcore *oc,
st = VTAILQ_NEXT(st, list);
if (st != NULL && st->len == 0)
st = NULL;
Lck_Unlock(&bo->boc->mtx);
assert(l > 0 || bo->boc->state == BOS_FINISHED);
Lck_Unlock(&boc->mtx);
assert(l > 0 || boc->state == BOS_FINISHED);
if (func(priv, st != NULL ? 0 : 1, p, l)) {
ret = -1;
break;
}
}
VBO_DerefBusyObj(wrk, &bo);
HSH_DerefBusy(wrk, &boc);
return (ret);
}
......
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