Commit bba23ef1 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Move obj.hits to objhead, make it read-only

parent 2001b7ef
......@@ -609,8 +609,6 @@ struct object {
struct exp exp;
/* VCL only variables */
long hits;
double last_modified;
struct http *http;
......
......@@ -433,6 +433,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++;
Lck_Unlock(&oh->mtx);
assert(HSH_DerefObjHead(&wrk->stats, &oh));
*ocp = oc;
......@@ -460,12 +462,11 @@ HSH_Lookup(struct req *req, struct objcore **ocp, struct objcore **bocp,
} else {
retval = HSH_EXP;
}
if (oh->hits < LONG_MAX)
oh->hits++;
Lck_Unlock(&oh->mtx);
if (retval == HSH_EXP)
assert(HSH_DerefObjHead(&wrk->stats, &oh));
if (!cache_param->obj_readonly && exp_o->hits < INT_MAX)
exp_o->hits++;
*ocp = exp_oc;
return (retval);
}
......
......@@ -36,6 +36,7 @@
#include "cache.h"
#include "common/heritage.h"
#include "hash/hash_slinger.h"
#include "cache_backend.h"
#include "vrt.h"
......@@ -570,29 +571,17 @@ VRT_r_server_hostname(const struct vrt_ctx *ctx)
/*--------------------------------------------------------------------*/
#define VOBJ_L(type, field) \
void \
VRT_l_obj_##field(const struct vrt_ctx *ctx, type a) \
{ \
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \
CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); \
CHECK_OBJ_NOTNULL(ctx->req->obj, OBJECT_MAGIC); \
ctx->req->obj->field = a; \
}
#define VOBJ_R(type, field) \
type \
VRT_r_obj_##field(const struct vrt_ctx *ctx) \
{ \
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC); \
CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC); \
CHECK_OBJ_NOTNULL(ctx->req->obj, OBJECT_MAGIC); \
return (ctx->req->obj->field); \
long
VRT_r_obj_hits(const struct vrt_ctx *ctx)
{
CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
CHECK_OBJ_NOTNULL(ctx->req, REQ_MAGIC);
CHECK_OBJ_NOTNULL(ctx->req->obj, OBJECT_MAGIC);
CHECK_OBJ_NOTNULL(ctx->req->obj->objcore, OBJCORE_MAGIC);
CHECK_OBJ_NOTNULL(ctx->req->obj->objcore->objhead, OBJHEAD_MAGIC);
return (ctx->req->obj->objcore->objhead->hits);
}
VOBJ_L(long, hits)
VOBJ_R(long, hits)
unsigned
VRT_r_obj_uncacheable(const struct vrt_ctx *ctx)
{
......
......@@ -94,6 +94,8 @@ 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).
......
......@@ -13,7 +13,6 @@ varnish v1 -vcl+backend {
sub vcl_deliver {
set resp.http.foo = obj.hits;
set obj.hits = obj.hits + 1;
}
} -start
......
......@@ -512,7 +512,7 @@ sp_variables = [
('obj.hits',
'INT',
( 'hit', 'deliver',),
( 'hit', 'deliver',), """
( ), """
The approximate number of times the object has been
delivered. A value of 0 indicates a cache miss.
This variable is also available in vcl_deliver.
......
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