/* Prefetch */
struct object *parent;
struct object *child;
+
+ int hits;
};
struct objhead {
#include <stdlib.h>
#include <math.h>
#include <string.h>
+#include <limits.h>
#include <sys/types.h>
#include <fcntl.h>
if (o != NULL) {
/* We found an object we like */
o->refcnt++;
+ if (o->hits < INT_MAX)
+ o->hits++;
UNLOCK(&oh->mtx);
if (params->log_hash)
WSP(sp, SLT_Hash, "%s", oh->hash);
return (TIM_real());
}
+int
+VRT_r_obj_hits(const struct sess *sp)
+{
+
+ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+ CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); /* XXX */
+ return (sp->obj->hits);
+}
+
double
VRT_r_obj_lastuse(const struct sess *sp)
{
txresp -body "2222\n"
} -start
-varnish v1 -vcl+backend {
+varnish v1 -arg "-p vcl_trace=on" -vcl+backend {
acl acl1 {
"localhost";
}
--- /dev/null
+# $Id$
+
+test "Check obj.hits"
+
+server s1 {
+ rxreq
+ expect req.url == "/"
+ txresp -body "slash"
+ rxreq
+ expect req.url == "/foo"
+ txresp -body "foo"
+} -start
+
+varnish v1 -vcl+backend {
+
+ sub vcl_deliver {
+ set resp.http.foo = obj.hits;
+ }
+} -start
+
+client c1 {
+ txreq
+ rxresp
+ expect resp.status == 200
+ expect resp.http.foo == 0
+
+ txreq
+ rxresp
+ expect resp.status == 200
+ expect resp.http.foo == 1
+
+ txreq -url /foo
+ rxresp
+ expect resp.status == 200
+ expect resp.http.foo == 0
+
+ txreq
+ rxresp
+ expect resp.status == 200
+ expect resp.http.foo == 2
+} -run
+
void VRT_l_obj_status(const struct sess *, int);
const char * VRT_r_obj_response(const struct sess *);
void VRT_l_obj_response(const struct sess *, const char *, ...);
+int VRT_r_obj_hits(const struct sess *);
unsigned VRT_r_obj_cacheable(const struct sess *);
void VRT_l_obj_cacheable(const struct sess *, unsigned);
double VRT_r_obj_ttl(const struct sess *);
{ fetch error}
"const struct sess *"
}
+ { obj.hits
+ RO INT
+ { hit fetch deliver }
+ "const struct sess *"
+ }
{ obj.http.
RW HDR_OBJ
{ hit fetch error}
0,
VCL_MET_FETCH | VCL_MET_ERROR
},
+ { "obj.hits", INT, 8,
+ "VRT_r_obj_hits(sp)",
+ NULL,
+ V_RO,
+ 0,
+ VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DELIVER
+ },
{ "obj.http.", HEADER, 9,
"VRT_r_obj_http_(sp)",
"VRT_l_obj_http_(sp, ",