Skip to content

Commit

Permalink
hash: Formally abandon objcores when not fetching
Browse files Browse the repository at this point in the history
This is the counterpart of HSH_Unbusy() for the cases where the req task
will not schedule a fetch task.
  • Loading branch information
dridi committed Jan 2, 2024
1 parent 82c1d4d commit 71d2938
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 2 deletions.
33 changes: 33 additions & 0 deletions bin/varnishd/cache/cache_hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -921,6 +921,39 @@ HSH_Cancel(struct worker *wrk, struct objcore *oc, struct boc *boc)
ObjSlim(wrk, oc);
}

/*---------------------------------------------------------------------
* Abandon an objcore that will not proceed with a fetch.
*/

int
HSH_Abandon(struct worker *wrk, struct objcore **ocp)
{
struct objhead *oh;
struct objcore *oc;
struct rush rush;

CHECK_OBJ_NOTNULL(wrk, WORKER_MAGIC);
TAKE_OBJ_NOTNULL(oc, ocp, OBJCORE_MAGIC);
INIT_OBJ(&rush, RUSH_MAGIC);

oh = oc->objhead;
CHECK_OBJ(oh, OBJHEAD_MAGIC);

Lck_Lock(&oh->mtx);
AN(oc->flags & OC_F_BUSY);
AZ(oc->flags & OC_F_PRIVATE);
AZ(oc->stobj->stevedore);
assert(oh->refcnt > 0);
assert(oc->refcnt > 0);
oc->flags &= ~OC_F_BUSY;
hsh_rush1(wrk, oc, &rush);
Lck_Unlock(&oh->mtx);

hsh_rush2(wrk, &rush);

return (HSH_DerefObjCore(wrk, &oc));
}

/*---------------------------------------------------------------------
* Unbusy an objcore when the object is completely fetched.
*/
Expand Down
1 change: 1 addition & 0 deletions bin/varnishd/cache/cache_objhead.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ enum lookup_e {
void HSH_Kill(struct objcore *);
void HSH_Insert(struct worker *, const void *hash, struct objcore *,
struct ban *);
int HSH_Abandon(struct worker *, struct objcore **);
void HSH_Unbusy(struct worker *, struct objcore *);
void HSH_Fail(struct worker *, struct objcore *);
int HSH_Snipe(const struct worker *, struct objcore *);
Expand Down
4 changes: 2 additions & 2 deletions bin/varnishd/cache/cache_req_fsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@ cnt_miss(struct worker *wrk, struct req *req)
VRY_Clear(req);
if (req->stale_oc != NULL)
(void)HSH_DerefObjCore(wrk, &req->stale_oc);
AZ(HSH_DerefObjCore(wrk, &req->objcore));
AZ(HSH_Abandon(wrk, &req->objcore));
return (REQ_FSM_MORE);
}

Expand Down Expand Up @@ -1093,7 +1093,7 @@ cnt_purge(struct worker *wrk, struct req *req)

(void)HSH_Purge(wrk, boc->objhead, req->t_req, 0, 0, 0);

AZ(HSH_DerefObjCore(wrk, &boc));
AZ(HSH_Abandon(wrk, &boc));

VCL_purge_method(req->vcl, wrk, req, NULL, NULL);
switch (wrk->vpi->handling) {
Expand Down

0 comments on commit 71d2938

Please sign in to comment.