]> err.no Git - varnish/commitdiff
Add "deliver" keyword to VCL compiler.
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sun, 18 Jun 2006 07:28:19 +0000 (07:28 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sun, 18 Jun 2006 07:28:19 +0000 (07:28 +0000)
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

varnish-cache/bin/varnishd/cache_vcl.c
varnish-cache/bin/varnishd/varnishd.c
varnish-cache/include/vcl_lang.h
varnish-cache/lib/libvcl/vcl_compile.c
varnish-cache/lib/libvcl/vcl_fixed_token.c
varnish-cache/lib/libvcl/vcl_gen_fixed_token.tcl
varnish-cache/lib/libvcl/vcl_token_defs.h

index e4e863b9805df380838a604396f89c2dc3a2555e..1e72f86c1e22dbe677e359d053750d2167ed5674 100644 (file)
@@ -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;
index 830579f551d756332f429c9d7a1f10e8e8a96083..2205ea34d6d96c976ea7b0de143f0039abf950cd 100644 (file)
@@ -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);
index 3cd1c5e56da09bf160ba13904ed1f1028a1aa6c5..59e19033b19b886eaf1353a3caa3061a243613ef 100644 (file)
@@ -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;
index cc10a57e95796f766704be339ec7c8b711e9abb4..6fb03a0ad25d145995fa905438a101a21bb74584 100644 (file)
@@ -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");
index e7479a8313b1f2c8f05d2a317263c1cf50d76fce..402332e75d85c338652a45e14432a13887e104de 100644 (file)
@@ -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);
index 7ebc242c8c6fc88094f7984655f3ec25a6822d4a..30c3e527466a04667761f8adc79d1bbf119e6e7d 100755 (executable)
@@ -16,12 +16,13 @@ set keywords {
        pass
        fetch
        insert
+       deliver
+
        call
        no_cache
        no_new_cache
        set
        rewrite
-       finish
        switch_config
 }
 
index d25a392c56da2653ca3aec176369bb78fee11c22..dde25c19bfa06f860e53282fbe69f2b0fc8f2e10 100644 (file)
 #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