r2341 - in trunk/varnish-cache: include lib/libvcl

phk at projects.linpro.no phk at projects.linpro.no
Mon Jan 14 10:14:57 CET 2008


Author: phk
Date: 2008-01-14 10:14:56 +0100 (Mon, 14 Jan 2008)
New Revision: 2341

Modified:
   trunk/varnish-cache/include/vcl.h
   trunk/varnish-cache/include/vcl_returns.h
   trunk/varnish-cache/include/vrt_obj.h
   trunk/varnish-cache/lib/libvcl/vcc_action.c
   trunk/varnish-cache/lib/libvcl/vcc_compile.h
   trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
   trunk/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl
   trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl
   trunk/varnish-cache/lib/libvcl/vcc_obj.c
   trunk/varnish-cache/lib/libvcl/vcc_parse.c
Log:
Add VCC support for:

Variables that can take relative, currently limited to negative,
time intervals.

vcl_prefetch{} method

obj.prefetch variable.



Modified: trunk/varnish-cache/include/vcl.h
===================================================================
--- trunk/varnish-cache/include/vcl.h	2008-01-14 08:55:58 UTC (rev 2340)
+++ trunk/varnish-cache/include/vcl.h	2008-01-14 09:14:56 UTC (rev 2341)
@@ -41,6 +41,7 @@
 	vcl_func_f	*hit_func;
 	vcl_func_f	*fetch_func;
 	vcl_func_f	*deliver_func;
+	vcl_func_f	*prefetch_func;
 	vcl_func_f	*timeout_func;
 	vcl_func_f	*discard_func;
 };

Modified: trunk/varnish-cache/include/vcl_returns.h
===================================================================
--- trunk/varnish-cache/include/vcl_returns.h	2008-01-14 08:55:58 UTC (rev 2340)
+++ trunk/varnish-cache/include/vcl_returns.h	2008-01-14 09:14:56 UTC (rev 2341)
@@ -44,6 +44,7 @@
 VCL_MET_MAC(hit,HIT,(VCL_RET_ERROR|VCL_RET_RESTART|VCL_RET_PASS|VCL_RET_DELIVER))
 VCL_MET_MAC(fetch,FETCH,(VCL_RET_ERROR|VCL_RET_RESTART|VCL_RET_PASS|VCL_RET_INSERT))
 VCL_MET_MAC(deliver,DELIVER,(VCL_RET_ERROR|VCL_RET_RESTART|VCL_RET_DELIVER))
+VCL_MET_MAC(prefetch,PREFETCH,(VCL_RET_FETCH|VCL_RET_PASS))
 VCL_MET_MAC(timeout,TIMEOUT,(VCL_RET_FETCH|VCL_RET_DISCARD))
 VCL_MET_MAC(discard,DISCARD,(VCL_RET_DISCARD|VCL_RET_KEEP))
 #else
@@ -55,7 +56,8 @@
 #define VCL_MET_HIT	(1 << 5)
 #define VCL_MET_FETCH	(1 << 6)
 #define VCL_MET_DELIVER	(1 << 7)
-#define VCL_MET_TIMEOUT	(1 << 8)
-#define VCL_MET_DISCARD	(1 << 9)
+#define VCL_MET_PREFETCH	(1 << 8)
+#define VCL_MET_TIMEOUT	(1 << 9)
+#define VCL_MET_DISCARD	(1 << 10)
 #endif
-#define N_METHODS 10
+#define N_METHODS 11

Modified: trunk/varnish-cache/include/vrt_obj.h
===================================================================
--- trunk/varnish-cache/include/vrt_obj.h	2008-01-14 08:55:58 UTC (rev 2340)
+++ trunk/varnish-cache/include/vrt_obj.h	2008-01-14 09:14:56 UTC (rev 2341)
@@ -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_prefetch(const struct sess *);
+void VRT_l_obj_prefetch(const struct sess *, double);
 double VRT_r_obj_lastuse(const struct sess *);
 const char * VRT_r_resp_proto(const struct sess *);
 void VRT_l_resp_proto(const struct sess *, const char *, ...);

Modified: trunk/varnish-cache/lib/libvcl/vcc_action.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_action.c	2008-01-14 08:55:58 UTC (rev 2340)
+++ trunk/varnish-cache/lib/libvcl/vcc_action.c	2008-01-14 09:14:56 UTC (rev 2341)
@@ -156,6 +156,7 @@
 	case SIZE:
 	case RATE:
 	case TIME:
+	case RTIME:
 	case FLOAT:
 		if (tl->t->tok != '=')
 			Fb(tl, 0, "%s %c ", vp->rname, *tl->t->b);
@@ -171,6 +172,8 @@
 		case '=':
 			if (vp->fmt == TIME)
 				vcc_TimeVal(tl);
+			else if (vp->fmt == RTIME)
+				vcc_RTimeVal(tl);
 			else if (vp->fmt == SIZE)
 				vcc_SizeVal(tl);
 			else if (vp->fmt == RATE)

Modified: trunk/varnish-cache/lib/libvcl/vcc_compile.h
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_compile.h	2008-01-14 08:55:58 UTC (rev 2340)
+++ trunk/varnish-cache/lib/libvcl/vcc_compile.h	2008-01-14 09:14:56 UTC (rev 2341)
@@ -95,6 +95,7 @@
 	SIZE,
 	RATE,
 	TIME,
+	RTIME,
 	STRING,
 	IP,
 	HOSTNAME,
@@ -174,6 +175,7 @@
 /* vcc_parse.c */
 void vcc_Parse(struct tokenlist *tl);
 void vcc_RateVal(struct tokenlist *tl);
+void vcc_RTimeVal(struct tokenlist *tl);
 void vcc_TimeVal(struct tokenlist *tl);
 void vcc_SizeVal(struct tokenlist *tl);
 unsigned vcc_UintVal(struct tokenlist *tl);

Modified: trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c	2008-01-14 08:55:58 UTC (rev 2340)
+++ trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c	2008-01-14 09:14:56 UTC (rev 2341)
@@ -374,6 +374,7 @@
 	vsb_cat(sb, "	vcl_func_f	*hit_func;\n");
 	vsb_cat(sb, "	vcl_func_f	*fetch_func;\n");
 	vsb_cat(sb, "	vcl_func_f	*deliver_func;\n");
+	vsb_cat(sb, "	vcl_func_f	*prefetch_func;\n");
 	vsb_cat(sb, "	vcl_func_f	*timeout_func;\n");
 	vsb_cat(sb, "	vcl_func_f	*discard_func;\n");
 	vsb_cat(sb, "};\n");
@@ -551,6 +552,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_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");
 	vsb_cat(sb, "const char * VRT_r_resp_proto(const struct sess *);\n");
 	vsb_cat(sb, "void VRT_l_resp_proto(const struct sess *, const char *, ...);\n");

Modified: trunk/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl	2008-01-14 08:55:58 UTC (rev 2340)
+++ trunk/varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl	2008-01-14 09:14:56 UTC (rev 2341)
@@ -42,6 +42,7 @@
 	{hit		{error restart pass deliver}}
 	{fetch		{error restart pass insert}}
 	{deliver	{error restart deliver}}
+	{prefetch	{fetch pass}}
 	{timeout	{fetch discard}}
 	{discard	{discard keep}}
 }

Modified: trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl	2008-01-14 08:55:58 UTC (rev 2340)
+++ trunk/varnish-cache/lib/libvcl/vcc_gen_obj.tcl	2008-01-14 09:14:56 UTC (rev 2341)
@@ -157,6 +157,11 @@
 		{                         hit fetch         discard timeout}
 		"const struct sess *"
 	}
+	{ obj.prefetch
+		RW RTIME
+		{ fetch prefetch }
+		"const struct sess *"
+	}
 	{ obj.lastuse
 		RO TIME
 		{                         hit fetch deliver discard timeout}
@@ -205,6 +210,7 @@
 set tt(BOOL)		"unsigned"
 set tt(BACKEND)		"struct backend *"
 set tt(TIME)		"double"
+set tt(RTIME)		"double"
 set tt(INT)		"int"
 set tt(HDR_RESP)	"const char *"
 set tt(HDR_OBJ)		"const char *"

Modified: trunk/varnish-cache/lib/libvcl/vcc_obj.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_obj.c	2008-01-14 08:55:58 UTC (rev 2340)
+++ trunk/varnish-cache/lib/libvcl/vcc_obj.c	2008-01-14 09:14:56 UTC (rev 2341)
@@ -182,6 +182,13 @@
 	    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, ",
+	    V_RW,
+	    0,
+	    VCL_MET_FETCH | VCL_MET_PREFETCH
+	},
 	{ "obj.lastuse", TIME, 11,
 	    "VRT_r_obj_lastuse(sp)",
 	    NULL,

Modified: trunk/varnish-cache/lib/libvcl/vcc_parse.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_parse.c	2008-01-14 08:55:58 UTC (rev 2340)
+++ trunk/varnish-cache/lib/libvcl/vcc_parse.c	2008-01-14 09:14:56 UTC (rev 2341)
@@ -184,6 +184,23 @@
 /*--------------------------------------------------------------------*/
 
 void
+vcc_RTimeVal(struct tokenlist *tl)
+{
+	double v, sc;
+	int sign = 1;
+
+	if (tl->t->tok == '-') {
+		sign *= -1;
+		vcc_NextToken(tl);
+	}
+	v = vcc_DoubleVal(tl);
+	ERRCHK(tl);
+	ExpectErr(tl, ID);
+	sc = TimeUnit(tl);
+	Fb(tl, 0, "(%d * %g * %g)", sign, v, sc);
+}
+
+void
 vcc_TimeVal(struct tokenlist *tl)
 {
 	double v, sc;




More information about the varnish-commit mailing list