]> err.no Git - varnish/commitdiff
Add a "timeout" method to VCL, it can return "fetch" or "discard".
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sat, 24 Jun 2006 21:07:18 +0000 (21:07 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sat, 24 Jun 2006 21:07:18 +0000 (21:07 +0000)
git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@228 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/bin/varnishd/varnishd.c
varnish-cache/include/vcl.h
varnish-cache/include/vcl_returns.h
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 b2d67c620e94b6e6928c1d2a0c7581093d600baf..7c72d149acf87586dd8bbfc07c19ef9440487a9b 100644 (file)
@@ -107,6 +107,9 @@ vcl_default(const char *bflag)
            "    }\n"
            "    insert;\n"
            "}\n"
+           "sub vcl_timeout {\n"
+           "    discard;\n"
+           "}\n"
            "", bflag);
        assert(buf != NULL);
        sb = sbuf_new(NULL, NULL, 0, SBUF_AUTOEXTEND);
index 831974341f9775fb661a92c272d31752b0af39dc..4b896ff04ac00e6d5b06363cb7cc3f2a653c126c 100644 (file)
@@ -27,4 +27,5 @@ struct VCL_conf {
        vcl_func_f      *miss_func;
        vcl_func_f      *hit_func;
        vcl_func_f      *fetch_func;
+       vcl_func_f      *timeout_func;
 };
index 0438e59daebf30c0970e97787ddb2d0039aa1c7c..3cc8448f4f1dd78c8f2d6ff141f8b5510e6f9c9f 100644 (file)
@@ -16,6 +16,7 @@ VCL_RET_MAC(pass, PASS, (1 << 3))
 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 @@ VCL_RET_MAC(deliver, DELIVER, (1 << 6))
 #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(recv,RECV,(VCL_RET_ERROR|VCL_RET_PASS|VCL_RET_PIPE|VCL_RET_LOOKUP))
 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
index 5e8203821772dacf43060a3e8ac63dff3adaf643..8f260f769a50c52859ffff4431b84f3c9d892adc 100644 (file)
@@ -180,6 +180,12 @@ vcl_fixed_token(const char *p, const char **q)
                }
                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_init_tnames(void)
        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 @@ vcl_output_lang_h(FILE *f)
        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 @@ vcl_output_lang_h(FILE *f)
        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);
index 371c4f1b416019ba1279bf6b46c8cc8317da3a7f..c25d7d9bca93e3c5bffeb1a644e429cc70eca41c 100755 (executable)
@@ -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 @@ set returns {
        fetch
        insert
        deliver
+       discard
 }
 
 # Language keywords
index 9a3f9382fc94323f0f1e1fae3f4c0d4ff7b4dea1..b3c2a02443d37265fbaaba5f4763c9f534ff1e2f 100644 (file)
 #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