r228 - in trunk/varnish-cache: bin/varnishd include lib/libvcl

phk at projects.linpro.no phk at projects.linpro.no
Sat Jun 24 23:07:18 CEST 2006


Author: phk
Date: 2006-06-24 23:07:18 +0200 (Sat, 24 Jun 2006)
New Revision: 228

Modified:
   trunk/varnish-cache/bin/varnishd/varnishd.c
   trunk/varnish-cache/include/vcl.h
   trunk/varnish-cache/include/vcl_returns.h
   trunk/varnish-cache/lib/libvcl/vcl_fixed_token.c
   trunk/varnish-cache/lib/libvcl/vcl_gen_fixed_token.tcl
   trunk/varnish-cache/lib/libvcl/vcl_token_defs.h
Log:
Add a "timeout" method to VCL, it can return "fetch" or "discard".


Modified: trunk/varnish-cache/bin/varnishd/varnishd.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/varnishd.c	2006-06-24 20:50:17 UTC (rev 227)
+++ trunk/varnish-cache/bin/varnishd/varnishd.c	2006-06-24 21:07:18 UTC (rev 228)
@@ -107,6 +107,9 @@
 	    "    }\n"
 	    "    insert;\n"
 	    "}\n"
+	    "sub vcl_timeout {\n"
+	    "    discard;\n"
+	    "}\n"
 	    "", bflag);
 	assert(buf != NULL);
 	sb = sbuf_new(NULL, NULL, 0, SBUF_AUTOEXTEND);

Modified: trunk/varnish-cache/include/vcl.h
===================================================================
--- trunk/varnish-cache/include/vcl.h	2006-06-24 20:50:17 UTC (rev 227)
+++ trunk/varnish-cache/include/vcl.h	2006-06-24 21:07:18 UTC (rev 228)
@@ -27,4 +27,5 @@
 	vcl_func_f	*miss_func;
 	vcl_func_f	*hit_func;
 	vcl_func_f	*fetch_func;
+	vcl_func_f	*timeout_func;
 };

Modified: trunk/varnish-cache/include/vcl_returns.h
===================================================================
--- trunk/varnish-cache/include/vcl_returns.h	2006-06-24 20:50:17 UTC (rev 227)
+++ trunk/varnish-cache/include/vcl_returns.h	2006-06-24 21:07:18 UTC (rev 228)
@@ -16,6 +16,7 @@
 VCL_RET_MAC(fetch, FETCH, (1 << 4))
 VCL_RET_MAC(insert, INSERT, (1 << 5))
 VCL_RET_MAC(deliver, DELIVER, (1 << 6))
+VCL_RET_MAC(discard, DISCARD, (1 << 7))
 #else
 #define VCL_RET_ERROR  (1 << 0)
 #define VCL_RET_LOOKUP  (1 << 1)
@@ -24,7 +25,8 @@
 #define VCL_RET_FETCH  (1 << 4)
 #define VCL_RET_INSERT  (1 << 5)
 #define VCL_RET_DELIVER  (1 << 6)
-#define VCL_RET_MAX 7
+#define VCL_RET_DISCARD  (1 << 7)
+#define VCL_RET_MAX 8
 #endif
 
 #ifdef VCL_MET_MAC
@@ -32,4 +34,5 @@
 VCL_MET_MAC(miss,MISS,(VCL_RET_ERROR|VCL_RET_PASS|VCL_RET_PIPE|VCL_RET_FETCH))
 VCL_MET_MAC(hit,HIT,(VCL_RET_ERROR|VCL_RET_PASS|VCL_RET_PIPE|VCL_RET_DELIVER))
 VCL_MET_MAC(fetch,FETCH,(VCL_RET_ERROR|VCL_RET_PASS|VCL_RET_PIPE|VCL_RET_INSERT))
+VCL_MET_MAC(timeout,TIMEOUT,(VCL_RET_FETCH|VCL_RET_DISCARD))
 #endif

Modified: trunk/varnish-cache/lib/libvcl/vcl_fixed_token.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcl_fixed_token.c	2006-06-24 20:50:17 UTC (rev 227)
+++ trunk/varnish-cache/lib/libvcl/vcl_fixed_token.c	2006-06-24 21:07:18 UTC (rev 228)
@@ -180,6 +180,12 @@
 		}
 		return (0);
 	case 'd':
+		if (p[0] == 'd' && p[1] == 'i' && p[2] == 's' && 
+		    p[3] == 'c' && p[4] == 'a' && p[5] == 'r' && 
+		    p[6] == 'd' && !isvar(p[7])) {
+			*q = p + 7;
+			return (T_DISCARD);
+		}
 		if (p[0] == 'd' && p[1] == 'e' && p[2] == 'l' && 
 		    p[3] == 'i' && p[4] == 'v' && p[5] == 'e' && 
 		    p[6] == 'r' && !isvar(p[7])) {
@@ -373,6 +379,7 @@
 	vcl_tnames[T_DEC] = "--";
 	vcl_tnames[T_DECR] = "/=";
 	vcl_tnames[T_DELIVER] = "deliver";
+	vcl_tnames[T_DISCARD] = "discard";
 	vcl_tnames[T_DIV] = "/=";
 	vcl_tnames[T_ELSE] = "else";
 	vcl_tnames[T_ELSEIF] = "elseif";
@@ -414,6 +421,7 @@
 	fputs("#define VCL_RET_FETCH  (1 << 4)\n", f);
 	fputs("#define VCL_RET_INSERT  (1 << 5)\n", f);
 	fputs("#define VCL_RET_DELIVER  (1 << 6)\n", f);
+	fputs("#define VCL_RET_DISCARD  (1 << 7)\n", f);
 	fputs("/*\n", f);
 	fputs(" * $Id$\n", f);
 	fputs(" *\n", f);
@@ -443,6 +451,7 @@
 	fputs("	vcl_func_f	*miss_func;\n", f);
 	fputs("	vcl_func_f	*hit_func;\n", f);
 	fputs("	vcl_func_f	*fetch_func;\n", f);
+	fputs("	vcl_func_f	*timeout_func;\n", f);
 	fputs("};\n", f);
 	fputs("/*\n", f);
 	fputs(" * $Id$ \n", f);

Modified: trunk/varnish-cache/lib/libvcl/vcl_gen_fixed_token.tcl
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcl_gen_fixed_token.tcl	2006-06-24 20:50:17 UTC (rev 227)
+++ trunk/varnish-cache/lib/libvcl/vcl_gen_fixed_token.tcl	2006-06-24 21:07:18 UTC (rev 228)
@@ -7,10 +7,11 @@
 # Second element is list of valid return actions.
 #
 set methods {
-	{recv	{error pass pipe lookup}}
-	{miss	{error pass pipe fetch}}
-	{hit	{error pass pipe deliver}}
-	{fetch	{error pass pipe insert}}
+	{recv		{error pass pipe lookup}}
+	{miss		{error pass pipe fetch}}
+	{hit		{error pass pipe deliver}}
+	{fetch		{error pass pipe insert}}
+	{timeout	{fetch discard}}
 }
 
 # These are the return actions
@@ -23,6 +24,7 @@
 	fetch
 	insert
 	deliver
+	discard
 }
 
 # Language keywords

Modified: trunk/varnish-cache/lib/libvcl/vcl_token_defs.h
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcl_token_defs.h	2006-06-24 20:50:17 UTC (rev 227)
+++ trunk/varnish-cache/lib/libvcl/vcl_token_defs.h	2006-06-24 21:07:18 UTC (rev 228)
@@ -29,23 +29,24 @@
 #define T_FETCH 147
 #define T_INSERT 148
 #define T_DELIVER 149
-#define T_INC 150
-#define T_DEC 151
-#define T_CAND 152
-#define T_COR 153
-#define T_LEQ 154
-#define T_EQ 155
-#define T_NEQ 156
-#define T_GEQ 157
-#define T_SHR 158
-#define T_SHL 159
-#define T_INCR 160
-#define T_DECR 161
-#define T_MUL 162
-#define T_DIV 163
-#define ID 164
-#define VAR 165
-#define CNUM 166
-#define CSTR 167
-#define EOI 168
-#define METHOD 169
+#define T_DISCARD 150
+#define T_INC 151
+#define T_DEC 152
+#define T_CAND 153
+#define T_COR 154
+#define T_LEQ 155
+#define T_EQ 156
+#define T_NEQ 157
+#define T_GEQ 158
+#define T_SHR 159
+#define T_SHL 160
+#define T_INCR 161
+#define T_DECR 162
+#define T_MUL 163
+#define T_DIV 164
+#define ID 165
+#define VAR 166
+#define CNUM 167
+#define CSTR 168
+#define EOI 169
+#define METHOD 170




More information about the varnish-commit mailing list