Commit e8c604b0 authored by Dag Haavi Finstad's avatar Dag Haavi Finstad

Move obj.hits to struct objcore. This gives us a separate hits counter

per object, in line with the functionality as it was in Varnish 3.0.
parent 94d1d0fd
......@@ -403,6 +403,7 @@ struct objcore {
struct objhead *objhead;
struct busyobj *busyobj;
double timer_when;
long hits;
struct exp exp;
......
......@@ -434,8 +434,8 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp,
assert(oh->refcnt > 1);
assert(oc->objhead == oh);
oc->refcnt++;
if (oh->hits < LONG_MAX)
oh->hits++;
if (oc->hits < LONG_MAX)
oc->hits++;
Lck_Unlock(&oh->mtx);
assert(HSH_DerefObjHead(wrk, &oh));
*ocp = oc;
......@@ -461,8 +461,8 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp,
AZ(req->hash_ignore_busy);
retval = HSH_EXP;
}
if (oh->hits < LONG_MAX)
oh->hits++;
if (exp_oc->hits < LONG_MAX)
exp_oc->hits++;
Lck_Unlock(&oh->mtx);
if (retval == HSH_EXP)
assert(HSH_DerefObjHead(wrk, &oh));
......
......@@ -651,8 +651,7 @@ VRT_r_obj_hits(VRT_CTX)
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC);
CHECK_OBJ_NOTNULL(ctx->req->objcore, OBJCORE_MAGIC);
CHECK_OBJ_NOTNULL(ctx->req->objcore->objhead, OBJHEAD_MAGIC);
return (ctx->req->objcore->objhead->hits);
return (ctx->req->objcore->hits);
}
unsigned
......
......@@ -94,8 +94,6 @@ struct objhead {
uint8_t digest[DIGEST_LEN];
struct waitinglist *waitinglist;
long hits;
/*----------------------------------------------------
* The fields below are for the sole private use of
* the hash implementation(s).
......
......@@ -31,19 +31,19 @@ client c1 {
expect resp.bodylen == 6
expect resp.http.hits == 1
# This is a miss on different vary -> hits still == 1
# This is a miss on different vary -> hits == 0
txreq -url "/" -hdr "Bar: 2"
rxresp
expect resp.status == 200
expect resp.bodylen == 4
expect resp.http.hits == 1
expect resp.http.hits == 0
# This is a hit -> hits == 2
# This is a hit -> hits == 1
txreq -url "/" -hdr "Bar: 2"
rxresp
expect resp.status == 200
expect resp.bodylen == 4
expect resp.http.hits == 2
expect resp.http.hits == 1
} -run
......
......@@ -571,13 +571,9 @@ sp_variables = [
'INT',
( 'hit', 'deliver',),
( ), """
The count of cache-hits on this hash-key since it was
last instantiated. This counts cache-hits across all
Vary:-ants on this hash-key.
The counter will only be reset to zero if/when all objects
with this hash-key have disappeared from cache.
NB: obj.hits == 0 does *not* indicate a cache miss.
"""
The count of cache-hits on this object. A value of 0 indicates a
cache miss.
"""
),
('obj.http.',
'HEADER',
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment