Permalink
Browse files

Simplify HSH_Lookup 3/N

Use req->hash_always_miss directly

Inspired by:    #2856
  • Loading branch information...
bsdphk committed Dec 4, 2018
1 parent 6567393 commit 44b9308ff267d946c95068a150e68a2bd46abee6
Showing with 7 additions and 8 deletions.
  1. +3 −4 bin/varnishd/cache/cache_hash.c
  2. +1 −2 bin/varnishd/cache/cache_objhead.h
  3. +3 −2 bin/varnishd/cache/cache_req_fsm.c
@@ -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,
@@ -482,7 +482,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
@@ -973,7 +973,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);

0 comments on commit 44b9308

Please sign in to comment.