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

phk at projects.linpro.no phk at projects.linpro.no
Sun Jun 18 09:28:20 CEST 2006


Author: phk
Date: 2006-06-18 09:28:19 +0200 (Sun, 18 Jun 2006)
New Revision: 195

Modified:
   trunk/varnish-cache/bin/varnishd/cache_vcl.c
   trunk/varnish-cache/bin/varnishd/varnishd.c
   trunk/varnish-cache/include/vcl_lang.h
   trunk/varnish-cache/lib/libvcl/vcl_compile.c
   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 "deliver" keyword to VCL compiler.

Split vcl_lookup() in vcl_hit() and vcl_miss()



Modified: trunk/varnish-cache/bin/varnishd/cache_vcl.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_vcl.c	2006-06-16 10:22:40 UTC (rev 194)
+++ trunk/varnish-cache/bin/varnishd/cache_vcl.c	2006-06-18 07:28:19 UTC (rev 195)
@@ -199,6 +199,7 @@
 }
 
 void VCL_insert(VCL_FARGS) { }
+void VCL_deliver(VCL_FARGS) { }
 
 void VCL_fetch(VCL_FARGS) { 
 	sess->handling = HND_Fetch;

Modified: trunk/varnish-cache/bin/varnishd/varnishd.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/varnishd.c	2006-06-16 10:22:40 UTC (rev 194)
+++ trunk/varnish-cache/bin/varnishd/varnishd.c	2006-06-18 07:28:19 UTC (rev 195)
@@ -85,19 +85,24 @@
 	    "    }\n"
 	    "}\n"
 	    "\n"
-	    "sub vcl_lookup {\n"
-	    "    if (!obj.valid) {\n"
-	    "        fetch;\n"
-	    "    }\n"
+	    "sub vcl_hit {\n"
 	    "    if (!obj.cacheable) {\n"
 	    "        pass;\n"
 	    "    }\n"
+	    "    deliver;\n"
 	    "}\n"
 	    "\n"
+	    "sub vcl_miss {\n"
+	    "    fetch;\n"
+	    "}\n"
+	    "\n"
 	    "sub vcl_fetch {\n"
 	    "    if (!obj.valid) {\n"
 	    "        error;\n"
 	    "    }\n"
+	    "    if (!obj.cacheable) {\n"
+	    "        pass;\n"
+	    "    }\n"
 	    "    insert;\n"
 	    "}\n"
 	    "", bflag);

Modified: trunk/varnish-cache/include/vcl_lang.h
===================================================================
--- trunk/varnish-cache/include/vcl_lang.h	2006-06-16 10:22:40 UTC (rev 194)
+++ trunk/varnish-cache/include/vcl_lang.h	2006-06-18 07:28:19 UTC (rev 195)
@@ -110,7 +110,8 @@
 #define VCL_CONF_MAGIC	0x7406c509	/* from /dev/random */
 	vcl_init_f	*init_func;
 	vcl_func_f	*recv_func;
-	vcl_func_f	*lookup_func;
+	vcl_func_f	*hit_func;
+	vcl_func_f	*miss_func;
 	vcl_func_f	*fetch_func;
 	struct backend	*default_backend;
 	struct vcl_ref	*ref;

Modified: trunk/varnish-cache/lib/libvcl/vcl_compile.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcl_compile.c	2006-06-16 10:22:40 UTC (rev 194)
+++ trunk/varnish-cache/lib/libvcl/vcl_compile.c	2006-06-18 07:28:19 UTC (rev 195)
@@ -892,7 +892,9 @@
 		I(tl);
 		sbuf_printf(tl->fc, "VCL_no_cache(VCL_PASS_ARGS);\n");
 		return;
-	case T_FINISH:
+	case T_DELIVER:
+		I(tl);
+		sbuf_printf(tl->fc, "VCL_deliver(VCL_PASS_ARGS);\n");
 		I(tl); sbuf_printf(tl->fc, "sess->done = 1;\n");
 		I(tl); sbuf_printf(tl->fc, "return;\n");
 		return;
@@ -1564,7 +1566,8 @@
 	sbuf_printf(tl->fc,
 	    "\t.init_func = VCL_Init,\n");
 	sbuf_printf(tl->fc, "\t.recv_func = VCL_function_vcl_recv,\n");
-	sbuf_printf(tl->fc, "\t.lookup_func = VCL_function_vcl_lookup,\n");
+	sbuf_printf(tl->fc, "\t.hit_func = VCL_function_vcl_hit,\n");
+	sbuf_printf(tl->fc, "\t.miss_func = VCL_function_vcl_miss,\n");
 	sbuf_printf(tl->fc, "\t.fetch_func = VCL_function_vcl_fetch,\n");
 	sbuf_printf(tl->fc,
 	    "\t.default_backend = &VCL_backend_default,\n");

Modified: trunk/varnish-cache/lib/libvcl/vcl_fixed_token.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcl_fixed_token.c	2006-06-16 10:22:40 UTC (rev 194)
+++ trunk/varnish-cache/lib/libvcl/vcl_fixed_token.c	2006-06-18 07:28:19 UTC (rev 195)
@@ -176,6 +176,14 @@
 			return (T_CALL);
 		}
 		return (0);
+	case 'd':
+		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])) {
+			*q = p + 7;
+			return (T_DELIVER);
+		}
+		return (0);
 	case 'e':
 		if (p[0] == 'e' && p[1] == 'r' && p[2] == 'r' && 
 		    p[3] == 'o' && p[4] == 'r' && !isvar(p[5])) {
@@ -205,12 +213,6 @@
 			*q = p + 4;
 			return (T_FUNC);
 		}
-		if (p[0] == 'f' && p[1] == 'i' && p[2] == 'n' && 
-		    p[3] == 'i' && p[4] == 's' && p[5] == 'h'
-		     && !isvar(p[6])) {
-			*q = p + 6;
-			return (T_FINISH);
-		}
 		if (p[0] == 'f' && p[1] == 'e' && p[2] == 't' && 
 		    p[3] == 'c' && p[4] == 'h' && !isvar(p[5])) {
 			*q = p + 5;
@@ -353,6 +355,7 @@
 	vcl_tnames[T_COR] = "||";
 	vcl_tnames[T_DEC] = "--";
 	vcl_tnames[T_DECR] = "/=";
+	vcl_tnames[T_DELIVER] = "deliver";
 	vcl_tnames[T_DIV] = "/=";
 	vcl_tnames[T_ELSE] = "else";
 	vcl_tnames[T_ELSEIF] = "elseif";
@@ -360,7 +363,6 @@
 	vcl_tnames[T_EQ] = "==";
 	vcl_tnames[T_ERROR] = "error";
 	vcl_tnames[T_FETCH] = "fetch";
-	vcl_tnames[T_FINISH] = "finish";
 	vcl_tnames[T_FUNC] = "func";
 	vcl_tnames[T_GEQ] = ">=";
 	vcl_tnames[T_IF] = "if";
@@ -498,7 +500,8 @@
 	fputs("#define VCL_CONF_MAGIC	0x7406c509	/* from /dev/random */\n", f);
 	fputs("	vcl_init_f	*init_func;\n", f);
 	fputs("	vcl_func_f	*recv_func;\n", f);
-	fputs("	vcl_func_f	*lookup_func;\n", f);
+	fputs("	vcl_func_f	*hit_func;\n", f);
+	fputs("	vcl_func_f	*miss_func;\n", f);
 	fputs("	vcl_func_f	*fetch_func;\n", f);
 	fputs("	struct backend	*default_backend;\n", f);
 	fputs("	struct vcl_ref	*ref;\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-16 10:22:40 UTC (rev 194)
+++ trunk/varnish-cache/lib/libvcl/vcl_gen_fixed_token.tcl	2006-06-18 07:28:19 UTC (rev 195)
@@ -16,12 +16,13 @@
 	pass
 	fetch
 	insert
+	deliver
+
 	call
 	no_cache
 	no_new_cache
 	set
 	rewrite
-	finish
 	switch_config
 }
 

Modified: trunk/varnish-cache/lib/libvcl/vcl_token_defs.h
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcl_token_defs.h	2006-06-16 10:22:40 UTC (rev 194)
+++ trunk/varnish-cache/lib/libvcl/vcl_token_defs.h	2006-06-18 07:28:19 UTC (rev 195)
@@ -17,12 +17,12 @@
 #define T_PASS 138
 #define T_FETCH 139
 #define T_INSERT 140
-#define T_CALL 141
-#define T_NO_CACHE 142
-#define T_NO_NEW_CACHE 143
-#define T_SET 144
-#define T_REWRITE 145
-#define T_FINISH 146
+#define T_DELIVER 141
+#define T_CALL 142
+#define T_NO_CACHE 143
+#define T_NO_NEW_CACHE 144
+#define T_SET 145
+#define T_REWRITE 146
 #define T_SWITCH_CONFIG 147
 #define T_INC 148
 #define T_DEC 149




More information about the varnish-commit mailing list