Skip to content

Commit

Permalink
hash: New HSH_Replace() function
Browse files Browse the repository at this point in the history
  • Loading branch information
dridi committed Mar 1, 2024
1 parent 241be56 commit b7507f9
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion bin/varnishd/cache/cache_fetch.c
Original file line number Diff line number Diff line change
Expand Up @@ -756,7 +756,7 @@ vbf_stp_fetchend(struct worker *wrk, struct busyobj *bo)
VSL(SLT_ExpKill, NO_VXID, "VBF_Superseded x=%ju n=%ju",
VXID(ObjGetXID(wrk, bo->stale_oc)),
VXID(ObjGetXID(wrk, bo->fetch_objcore)));
HSH_Kill(bo->stale_oc);
HSH_Replace(bo->stale_oc, bo->fetch_objcore);
}
return (F_STP_DONE);
}
Expand Down
13 changes: 12 additions & 1 deletion bin/varnishd/cache/cache_hash.c
Original file line number Diff line number Diff line change
Expand Up @@ -911,15 +911,26 @@ HSH_Unbusy(struct worker *wrk, struct objcore *oc)

void
HSH_Kill(struct objcore *oc)
{

HSH_Replace(oc, NULL);
}

void
HSH_Replace(struct objcore *oc, const struct objcore *new_oc)
{

CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
CHECK_OBJ_NOTNULL(oc->objhead, OBJHEAD_MAGIC);
if (new_oc != NULL) {
CHECK_OBJ(new_oc, OBJCORE_MAGIC);
assert(oc->objhead == new_oc->objhead);
}

Lck_Lock(&oc->objhead->mtx);
oc->flags |= OC_F_DYING;
Lck_Unlock(&oc->objhead->mtx);
EXP_Remove(oc, NULL);
EXP_Remove(oc, new_oc);
}

/*====================================================================
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 @@ -67,6 +67,7 @@ enum lookup_e {

void HSH_Fail(struct objcore *);
void HSH_Kill(struct objcore *);
void HSH_Replace(struct objcore *, const struct objcore *);
void HSH_Insert(struct worker *, const void *hash, struct objcore *,
struct ban *);
void HSH_Unbusy(struct worker *, struct objcore *);
Expand Down
2 changes: 2 additions & 0 deletions bin/varnishtest/tests/b00039.vtc
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,5 @@ client c1 {
} -run

logexpect l1 -wait

varnish v1 -expect MAIN.n_superseded == 2

0 comments on commit b7507f9

Please sign in to comment.