Commit b7507f94 authored by Dridi Boukelmoune's avatar Dridi Boukelmoune

hash: New HSH_Replace() function

parent 241be56b
......@@ -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);
}
......
......@@ -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);
}
/*====================================================================
......
......@@ -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 *);
......
......@@ -67,3 +67,5 @@ client c1 {
} -run
logexpect l1 -wait
varnish v1 -expect MAIN.n_superseded == 2
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