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 { ...@@ -403,6 +403,7 @@ struct objcore {
struct objhead *objhead; struct objhead *objhead;
struct busyobj *busyobj; struct busyobj *busyobj;
double timer_when; double timer_when;
long hits;
struct exp exp; struct exp exp;
......
...@@ -434,8 +434,8 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, ...@@ -434,8 +434,8 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp,
assert(oh->refcnt > 1); assert(oh->refcnt > 1);
assert(oc->objhead == oh); assert(oc->objhead == oh);
oc->refcnt++; oc->refcnt++;
if (oh->hits < LONG_MAX) if (oc->hits < LONG_MAX)
oh->hits++; oc->hits++;
Lck_Unlock(&oh->mtx); Lck_Unlock(&oh->mtx);
assert(HSH_DerefObjHead(wrk, &oh)); assert(HSH_DerefObjHead(wrk, &oh));
*ocp = oc; *ocp = oc;
...@@ -461,8 +461,8 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp, ...@@ -461,8 +461,8 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp,
AZ(req->hash_ignore_busy); AZ(req->hash_ignore_busy);
retval = HSH_EXP; retval = HSH_EXP;
} }
if (oh->hits < LONG_MAX) if (exp_oc->hits < LONG_MAX)
oh->hits++; exp_oc->hits++;
Lck_Unlock(&oh->mtx); Lck_Unlock(&oh->mtx);
if (retval == HSH_EXP) if (retval == HSH_EXP)
assert(HSH_DerefObjHead(wrk, &oh)); assert(HSH_DerefObjHead(wrk, &oh));
......
...@@ -651,8 +651,7 @@ VRT_r_obj_hits(VRT_CTX) ...@@ -651,8 +651,7 @@ VRT_r_obj_hits(VRT_CTX)
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC);
CHECK_OBJ_NOTNULL(ctx->req->objcore, OBJCORE_MAGIC); CHECK_OBJ_NOTNULL(ctx->req->objcore, OBJCORE_MAGIC);
CHECK_OBJ_NOTNULL(ctx->req->objcore->objhead, OBJHEAD_MAGIC); return (ctx->req->objcore->hits);
return (ctx->req->objcore->objhead->hits);
} }
unsigned unsigned
......
...@@ -94,8 +94,6 @@ struct objhead { ...@@ -94,8 +94,6 @@ struct objhead {
uint8_t digest[DIGEST_LEN]; uint8_t digest[DIGEST_LEN];
struct waitinglist *waitinglist; struct waitinglist *waitinglist;
long hits;
/*---------------------------------------------------- /*----------------------------------------------------
* The fields below are for the sole private use of * The fields below are for the sole private use of
* the hash implementation(s). * the hash implementation(s).
......
...@@ -31,19 +31,19 @@ client c1 { ...@@ -31,19 +31,19 @@ client c1 {
expect resp.bodylen == 6 expect resp.bodylen == 6
expect resp.http.hits == 1 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" txreq -url "/" -hdr "Bar: 2"
rxresp rxresp
expect resp.status == 200 expect resp.status == 200
expect resp.bodylen == 4 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" txreq -url "/" -hdr "Bar: 2"
rxresp rxresp
expect resp.status == 200 expect resp.status == 200
expect resp.bodylen == 4 expect resp.bodylen == 4
expect resp.http.hits == 2 expect resp.http.hits == 1
} -run } -run
......
...@@ -571,13 +571,9 @@ sp_variables = [ ...@@ -571,13 +571,9 @@ sp_variables = [
'INT', 'INT',
( 'hit', 'deliver',), ( 'hit', 'deliver',),
( ), """ ( ), """
The count of cache-hits on this hash-key since it was The count of cache-hits on this object. A value of 0 indicates a
last instantiated. This counts cache-hits across all cache miss.
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.
"""
), ),
('obj.http.', ('obj.http.',
'HEADER', '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