[6.0] 91c3dfc03 Introduce HSH_HITPASS and HSH_HITMISS and clarify grace/keep HSH_HITMISS
Dridi Boukelmoune
dridi.boukelmoune at gmail.com
Fri Feb 8 13:13:09 UTC 2019
commit 91c3dfc03b2369fe2d8efe27376a638f88375cbe
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 4ee3dbce6..66fd223f5 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 65c90e6b7..85af28381 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -516,21 +516,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