Commit 71891866 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp Committed by Dridi Boukelmoune

Simplify HSH_Lookup 3/N

Use req->hash_always_miss directly

Inspired by:    #2856
parent 5ee0e257
......@@ -338,8 +338,7 @@ hsh_insert_busyobj(struct worker *wrk, struct objhead *oh)
*/
enum lookup_e
HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp,
int always_insert)
HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp)
{
struct worker *wrk;
struct objhead *oh;
......@@ -384,7 +383,7 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp,
CHECK_OBJ_NOTNULL(oh, OBJHEAD_MAGIC);
Lck_AssertHeld(&oh->mtx);
if (always_insert) {
if (req->hash_always_miss) {
/* XXX: should we do predictive Vary in this case ? */
/* Insert new objcore in objecthead and release mutex */
*bocp = hsh_insert_busyobj(wrk, oh);
......@@ -472,7 +471,7 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp,
wrk->stats->cache_hitmiss++;
VSLb(req->vsl, SLT_HitMiss, "%u %.6f", xid, dttl);
return (HSH_HITMISS);
}
}
if (oc->hits < LONG_MAX)
oc->hits++;
AN(hsh_deref_objhead_unlock(wrk, &oh));
......
......@@ -68,8 +68,7 @@ int HSH_DerefObjCore(struct worker *, struct objcore **, int rushmax);
#define HSH_RUSH_POLICY -1
#define HSH_RUSH_ALL INT_MAX
enum lookup_e HSH_Lookup(struct req *, struct objcore **, struct objcore **,
int always_insert);
enum lookup_e HSH_Lookup(struct req *, struct objcore **, struct objcore **);
void HSH_Ref(struct objcore *o);
void HSH_AddString(struct req *, void *ctx, const char *str);
unsigned HSH_Purge(struct worker *, struct objhead *, vtim_real ttl_now,
......
......@@ -495,7 +495,7 @@ cnt_lookup(struct worker *wrk, struct req *req)
AZ(req->objcore);
if (req->hash_objhead)
had_objhead = 1;
lr = HSH_Lookup(req, &oc, &busy, req->hash_always_miss ? 1 : 0);
lr = HSH_Lookup(req, &oc, &busy);
if (lr == HSH_BUSY) {
/*
* We lost the session to a busy object, disembark the
......@@ -986,7 +986,8 @@ cnt_purge(struct worker *wrk, struct req *req)
VRY_Prep(req);
AZ(req->objcore);
lr = HSH_Lookup(req, &oc, &boc, 1);
req->hash_always_miss = 1;
lr = HSH_Lookup(req, &oc, &boc);
assert (lr == HSH_MISS);
AZ(oc);
CHECK_OBJ_NOTNULL(boc, OBJCORE_MAGIC);
......
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