Commit 206d6ab5 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Add "deliver" keyword to VCL compiler.

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



git-svn-id: http://www.varnish-cache.org/svn/trunk@195 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent e6eec9b8
......@@ -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;
......
......@@ -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);
......
......@@ -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;
......
......@@ -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");
......
......@@ -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);
......
......@@ -16,12 +16,13 @@ set keywords {
pass
fetch
insert
deliver
call
no_cache
no_new_cache
set
rewrite
finish
switch_config
}
......
......@@ -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
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment