[master] b637c111d Make obj.hits a native VCL_INT which are always 64 bit, so we can avoid the LONG_MAX check.

Poul-Henning Kamp phk at FreeBSD.org
Wed Dec 5 08:23:10 UTC 2018


commit b637c111d6db652f7849c0d68fa19491f0f9c598
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date:   Wed Dec 5 08:22:13 2018 +0000

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

diff --git a/bin/varnishd/cache/cache.h b/bin/varnishd/cache/cache.h
index 2b13aa9ce..b7e6e1f7e 100644
--- a/bin/varnishd/cache/cache.h
+++ b/bin/varnishd/cache/cache.h
@@ -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;
diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c
index ac2af79a0..d6c2fded9 100644
--- a/bin/varnishd/cache/cache_hash.c
+++ b/bin/varnishd/cache/cache_hash.c
@@ -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);
 	}


More information about the varnish-commit mailing list