Permalink
Browse files

Make obj.hits a native VCL_INT which are always 64 bit, so we can

avoid the LONG_MAX check.
  • Loading branch information...
bsdphk committed Dec 5, 2018
1 parent a9b537e commit b637c111d6db652f7849c0d68fa19491f0f9c598
Showing with 5 additions and 7 deletions.
  1. +2 −1 bin/varnishd/cache/cache.h
  2. +3 −6 bin/varnishd/cache/cache_hash.c
@@ -346,7 +346,8 @@ struct objcore {
struct objhead *objhead;
struct boc *boc;
vtim_real timer_when;
long hits;
VCL_INT hits;
vtim_real t_origin;
float ttl;
@@ -473,8 +473,7 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp)
VSLb(req->vsl, SLT_HitMiss, "%u %.6f", xid, dttl);
return (HSH_HITMISS);
}
if (oc->hits < LONG_MAX)
oc->hits++;
oc->hits++;
AN(hsh_deref_objhead_unlock(wrk, &oh));
return (HSH_HIT);
}
@@ -502,8 +501,7 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp)
exp_oc->refcnt++;
*ocp = exp_oc;
if (EXP_Ttl_grace(req, exp_oc) > req->t_req) {
if (exp_oc->hits < LONG_MAX)
exp_oc->hits++;
exp_oc->hits++;
Lck_Unlock(&oh->mtx);
return (HSH_GRACE);
}
@@ -517,8 +515,7 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp)
/* we do not wait on the busy object if in grace */
exp_oc->refcnt++;
*ocp = exp_oc;
if (exp_oc->hits < LONG_MAX)
exp_oc->hits++;
exp_oc->hits++;
AN(hsh_deref_objhead_unlock(wrk, &oh));
return (HSH_GRACE);
}

0 comments on commit b637c11

Please sign in to comment.