[master] ed4ed27f1 Introduce HSH_HITPASS and HSH_HITMISS and clarify grace/keep HSH_HITMISS

Nils Goroll nils.goroll at uplex.de
Mon Dec 3 21:20:10 UTC 2018


commit ed4ed27f1c24a9b336d6462d198d6518358bb202
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Mon Dec 3 21:34:12 2018 +0100

    Introduce HSH_HITPASS and HSH_HITMISS and clarify grace/keep HSH_HITMISS

diff --git a/bin/varnishd/cache/cache_hash.c b/bin/varnishd/cache/cache_hash.c
index 1d615d28b..8e59f101d 100644
--- a/bin/varnishd/cache/cache_hash.c
+++ b/bin/varnishd/cache/cache_hash.c
@@ -444,14 +444,14 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp,
 				VSLb(req->vsl, SLT_HitPass, "%u %.6f",
 				    ObjGetXID(wrk, oc), EXP_Dttl(req, oc));
 				oc = NULL;
-				retval = HSH_MISS;
+				retval = HSH_HITPASS;
 			} else if (oc->flags & OC_F_HFM) {
 				wrk->stats->cache_hitmiss++;
 				VSLb(req->vsl, SLT_HitMiss, "%u %.6f",
 				    ObjGetXID(wrk, oc), EXP_Dttl(req, oc));
 				*bocp = hsh_insert_busyobj(wrk, oh);
 				oc->refcnt++;
-				retval = HSH_MISS;
+				retval = HSH_HITMISS;
 			} else {
 				oc->refcnt++;
 				if (oc->hits < LONG_MAX)
@@ -473,11 +473,17 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp,
 	}
 
 	if (exp_oc != NULL && exp_oc->flags & OC_F_HFM) {
+		/*
+		 * expired HFM ("grace/keep HFM")
+		 *
+		 * XXX should HFM objects actually have grace/keep ?
+		 */
 		wrk->stats->cache_hitmiss++;
 		VSLb(req->vsl, SLT_HitMiss, "%u %.6f", ObjGetXID(wrk, exp_oc),
 		    EXP_Dttl(req, exp_oc));
-		exp_oc = NULL;
-		busy_found = 0;
+		*bocp = hsh_insert_busyobj(wrk, oh);
+		Lck_Unlock(&oh->mtx);
+		return (HSH_HITMISS);
 	}
 
 	if (!busy_found) {
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 33010aba9..477e4f468 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -503,21 +503,23 @@ cnt_lookup(struct worker *wrk, struct req *req)
 	}
 
 	AZ(req->objcore);
-	if (lr == HSH_MISS) {
-		if (busy != NULL) {
-			/* hitmiss, out-of-grace or ordinary miss */
-			AN(busy->flags & OC_F_BUSY);
-			req->objcore = busy;
-			req->stale_oc = oc;
-			req->req_step = R_STP_MISS;
-		} else {
-			/* hitpass */
-			AZ(oc);
-			req->req_step = R_STP_PASS;
-		}
+	if (lr == HSH_MISS || lr == HSH_HITMISS) {
+		AN(busy);
+		AN(busy->flags & OC_F_BUSY);
+		req->objcore = busy;
+		req->stale_oc = oc;
+		req->req_step = R_STP_MISS;
+		return (REQ_FSM_MORE);
+	}
+	if (lr == HSH_HITPASS) {
+		AZ(busy);
+		AZ(oc);
+		req->req_step = R_STP_PASS;
 		return (REQ_FSM_MORE);
 	}
 
+	assert(lr == HSH_HIT || lr == HSH_GRACE);
+
 	CHECK_OBJ_NOTNULL(oc, OBJCORE_MAGIC);
 	AZ(oc->flags & OC_F_BUSY);
 	req->objcore = oc;
diff --git a/bin/varnishd/hash/hash_slinger.h b/bin/varnishd/hash/hash_slinger.h
index aa4f284f4..9434ce874 100644
--- a/bin/varnishd/hash/hash_slinger.h
+++ b/bin/varnishd/hash/hash_slinger.h
@@ -53,6 +53,8 @@ enum lookup_e {
 	HSH_MISS,
 	HSH_BUSY,
 	HSH_HIT,
+	HSH_HITMISS,
+	HSH_HITPASS,
 	HSH_GRACE
 };
 


More information about the varnish-commit mailing list