r2391 - in trunk/varnish-cache: bin/varnishd include lib/libvcl
phk at projects.linpro.no
phk at projects.linpro.no
Mon Jan 28 10:28:49 CET 2008
Author: phk
Date: 2008-01-28 10:28:47 +0100 (Mon, 28 Jan 2008)
New Revision: 2391
Modified:
trunk/varnish-cache/bin/varnishd/cache.h
trunk/varnish-cache/bin/varnishd/cache_vrt.c
trunk/varnish-cache/include/vrt_obj.h
trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl
trunk/varnish-cache/lib/libvcl/vcc_obj.c
Log:
Introduce obj.grace variable:
The amount of time after obj.ttl this object can be served, provided
we are already trying to fetch a new copy.
Nothing inspects this variable yet.
Modified: trunk/varnish-cache/bin/varnishd/cache.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache.h 2008-01-28 09:09:12 UTC (rev 2390)
+++ trunk/varnish-cache/bin/varnishd/cache.h 2008-01-28 09:28:47 UTC (rev 2391)
@@ -256,6 +256,7 @@
double age;
double entered;
double ttl;
+ double grace;
double prefetch;
double last_modified;
Modified: trunk/varnish-cache/bin/varnishd/cache_vrt.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vrt.c 2008-01-28 09:09:12 UTC (rev 2390)
+++ trunk/varnish-cache/bin/varnishd/cache_vrt.c 2008-01-28 09:28:47 UTC (rev 2391)
@@ -304,6 +304,29 @@
return (sp->obj->ttl - sp->t_req);
}
+/*--------------------------------------------------------------------
+ * obj.grace is relative to obj.ttl, so no special magic is necessary.
+ */
+
+void
+VRT_l_obj_grace(const struct sess *sp, double a)
+{
+
+ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+ CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); /* XXX */
+ if (a < 0)
+ a = 0;
+ sp->obj->grace = a;
+}
+
+double
+VRT_r_obj_grace(const struct sess *sp)
+{
+ CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
+ CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC); /* XXX */
+ return (sp->obj->grace);
+}
+
/*--------------------------------------------------------------------*/
/* XXX: the VCL_info messages has unexpected fractions on the ttl */
Modified: trunk/varnish-cache/include/vrt_obj.h
===================================================================
--- trunk/varnish-cache/include/vrt_obj.h 2008-01-28 09:09:12 UTC (rev 2390)
+++ trunk/varnish-cache/include/vrt_obj.h 2008-01-28 09:28:47 UTC (rev 2391)
@@ -40,6 +40,8 @@
void VRT_l_obj_cacheable(const struct sess *, unsigned);
double VRT_r_obj_ttl(const struct sess *);
void VRT_l_obj_ttl(const struct sess *, double);
+double VRT_r_obj_grace(const struct sess *);
+void VRT_l_obj_grace(const struct sess *, double);
double VRT_r_obj_prefetch(const struct sess *);
void VRT_l_obj_prefetch(const struct sess *, double);
double VRT_r_obj_lastuse(const struct sess *);
Modified: trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c 2008-01-28 09:09:12 UTC (rev 2390)
+++ trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c 2008-01-28 09:28:47 UTC (rev 2391)
@@ -539,6 +539,8 @@
vsb_cat(sb, "void VRT_l_obj_cacheable(const struct sess *, unsigned);\n");
vsb_cat(sb, "double VRT_r_obj_ttl(const struct sess *);\n");
vsb_cat(sb, "void VRT_l_obj_ttl(const struct sess *, double);\n");
+ vsb_cat(sb, "double VRT_r_obj_grace(const struct sess *);\n");
+ vsb_cat(sb, "void VRT_l_obj_grace(const struct sess *, double);\n");
vsb_cat(sb, "double VRT_r_obj_prefetch(const struct sess *);\n");
vsb_cat(sb, "void VRT_l_obj_prefetch(const struct sess *, double);\n");
vsb_cat(sb, "double VRT_r_obj_lastuse(const struct sess *);\n");
Modified: trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl 2008-01-28 09:09:12 UTC (rev 2390)
+++ trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl 2008-01-28 09:28:47 UTC (rev 2391)
@@ -157,6 +157,11 @@
{ hit fetch discard timeout}
"const struct sess *"
}
+ { obj.grace
+ RW TIME
+ { hit fetch discard timeout}
+ "const struct sess *"
+ }
{ obj.prefetch
RW RTIME
{ fetch prefetch }
Modified: trunk/varnish-cache/lib/libvcl/vcc_obj.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_obj.c 2008-01-28 09:09:12 UTC (rev 2390)
+++ trunk/varnish-cache/lib/libvcl/vcc_obj.c 2008-01-28 09:28:47 UTC (rev 2391)
@@ -182,6 +182,13 @@
0,
VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DISCARD | VCL_MET_TIMEOUT
},
+ { "obj.grace", TIME, 9,
+ "VRT_r_obj_grace(sp)",
+ "VRT_l_obj_grace(sp, ",
+ V_RW,
+ 0,
+ VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DISCARD | VCL_MET_TIMEOUT
+ },
{ "obj.prefetch", RTIME, 12,
"VRT_r_obj_prefetch(sp)",
"VRT_l_obj_prefetch(sp, ",
More information about the varnish-commit
mailing list