From: phk Date: Sun, 18 Jun 2006 07:28:19 +0000 (+0000) Subject: Add "deliver" keyword to VCL compiler. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=30eccc40dcc6bb9b6f8e87a659dd6e7983464b13;p=varnish Add "deliver" keyword to VCL compiler. Split vcl_lookup() in vcl_hit() and vcl_miss() git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@195 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache_vcl.c b/varnish-cache/bin/varnishd/cache_vcl.c index e4e863b9..1e72f86c 100644 --- a/varnish-cache/bin/varnishd/cache_vcl.c +++ b/varnish-cache/bin/varnishd/cache_vcl.c @@ -199,6 +199,7 @@ VCL_pass(VCL_FARGS) } void VCL_insert(VCL_FARGS) { } +void VCL_deliver(VCL_FARGS) { } void VCL_fetch(VCL_FARGS) { sess->handling = HND_Fetch; diff --git a/varnish-cache/bin/varnishd/varnishd.c b/varnish-cache/bin/varnishd/varnishd.c index 830579f5..2205ea34 100644 --- a/varnish-cache/bin/varnishd/varnishd.c +++ b/varnish-cache/bin/varnishd/varnishd.c @@ -85,19 +85,24 @@ vcl_default(const char *bflag) " }\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); diff --git a/varnish-cache/include/vcl_lang.h b/varnish-cache/include/vcl_lang.h index 3cd1c5e5..59e19033 100644 --- a/varnish-cache/include/vcl_lang.h +++ b/varnish-cache/include/vcl_lang.h @@ -110,7 +110,8 @@ struct VCL_conf { #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; diff --git a/varnish-cache/lib/libvcl/vcl_compile.c b/varnish-cache/lib/libvcl/vcl_compile.c index cc10a57e..6fb03a0a 100644 --- a/varnish-cache/lib/libvcl/vcl_compile.c +++ b/varnish-cache/lib/libvcl/vcl_compile.c @@ -892,7 +892,9 @@ Action(struct tokenlist *tl) 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 @@ EmitStruct(struct tokenlist *tl) 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"); diff --git a/varnish-cache/lib/libvcl/vcl_fixed_token.c b/varnish-cache/lib/libvcl/vcl_fixed_token.c index e7479a83..402332e7 100644 --- a/varnish-cache/lib/libvcl/vcl_fixed_token.c +++ b/varnish-cache/lib/libvcl/vcl_fixed_token.c @@ -176,6 +176,14 @@ vcl_fixed_token(const char *p, const char **q) 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 @@ vcl_fixed_token(const char *p, const char **q) *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_init_tnames(void) 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_init_tnames(void) 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 @@ vcl_output_lang_h(FILE *f) 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); diff --git a/varnish-cache/lib/libvcl/vcl_gen_fixed_token.tcl b/varnish-cache/lib/libvcl/vcl_gen_fixed_token.tcl index 7ebc242c..30c3e527 100755 --- a/varnish-cache/lib/libvcl/vcl_gen_fixed_token.tcl +++ b/varnish-cache/lib/libvcl/vcl_gen_fixed_token.tcl @@ -16,12 +16,13 @@ set keywords { pass fetch insert + deliver + call no_cache no_new_cache set rewrite - finish switch_config } diff --git a/varnish-cache/lib/libvcl/vcl_token_defs.h b/varnish-cache/lib/libvcl/vcl_token_defs.h index d25a392c..dde25c19 100644 --- a/varnish-cache/lib/libvcl/vcl_token_defs.h +++ b/varnish-cache/lib/libvcl/vcl_token_defs.h @@ -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