]> err.no Git - varnish/commitdiff
Add VCC support for:
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 14 Jan 2008 09:14:56 +0000 (09:14 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Mon, 14 Jan 2008 09:14:56 +0000 (09:14 +0000)
Variables that can take relative, currently limited to negative,
time intervals.

vcl_prefetch{} method

obj.prefetch variable.

git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2341 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/include/vcl.h
varnish-cache/include/vcl_returns.h
varnish-cache/include/vrt_obj.h
varnish-cache/lib/libvcl/vcc_action.c
varnish-cache/lib/libvcl/vcc_compile.h
varnish-cache/lib/libvcl/vcc_fixed_token.c
varnish-cache/lib/libvcl/vcc_gen_fixed_token.tcl
varnish-cache/lib/libvcl/vcc_gen_obj.tcl
varnish-cache/lib/libvcl/vcc_obj.c
varnish-cache/lib/libvcl/vcc_parse.c

index b6bb447e67ae9dd90dca6a42ecd4d3b4db582dfc..8973590bb2795f5cfeebde37ffebe136d3e9cb20 100644 (file)
@@ -41,6 +41,7 @@ struct VCL_conf {
        vcl_func_f      *hit_func;
        vcl_func_f      *fetch_func;
        vcl_func_f      *deliver_func;
+       vcl_func_f      *prefetch_func;
        vcl_func_f      *timeout_func;
        vcl_func_f      *discard_func;
 };
index 76ad3f6af15d1ea62e40100e90a4c30afccdebbe..d69c8d65aa7a2d9deec662ff6b1dfb9f2022a92a 100644 (file)
@@ -44,6 +44,7 @@ VCL_MET_MAC(miss,MISS,(VCL_RET_ERROR|VCL_RET_RESTART|VCL_RET_PASS|VCL_RET_FETCH)
 VCL_MET_MAC(hit,HIT,(VCL_RET_ERROR|VCL_RET_RESTART|VCL_RET_PASS|VCL_RET_DELIVER))
 VCL_MET_MAC(fetch,FETCH,(VCL_RET_ERROR|VCL_RET_RESTART|VCL_RET_PASS|VCL_RET_INSERT))
 VCL_MET_MAC(deliver,DELIVER,(VCL_RET_ERROR|VCL_RET_RESTART|VCL_RET_DELIVER))
+VCL_MET_MAC(prefetch,PREFETCH,(VCL_RET_FETCH|VCL_RET_PASS))
 VCL_MET_MAC(timeout,TIMEOUT,(VCL_RET_FETCH|VCL_RET_DISCARD))
 VCL_MET_MAC(discard,DISCARD,(VCL_RET_DISCARD|VCL_RET_KEEP))
 #else
@@ -55,7 +56,8 @@ VCL_MET_MAC(discard,DISCARD,(VCL_RET_DISCARD|VCL_RET_KEEP))
 #define VCL_MET_HIT    (1 << 5)
 #define VCL_MET_FETCH  (1 << 6)
 #define VCL_MET_DELIVER        (1 << 7)
-#define VCL_MET_TIMEOUT        (1 << 8)
-#define VCL_MET_DISCARD        (1 << 9)
+#define VCL_MET_PREFETCH       (1 << 8)
+#define VCL_MET_TIMEOUT        (1 << 9)
+#define VCL_MET_DISCARD        (1 << 10)
 #endif
-#define N_METHODS 10
+#define N_METHODS 11
index f8a9cd4a1855aa58b0a6422273936bb1bd8e8153..ca2d87370bd19e20b9e2eb324105495adac202e6 100644 (file)
@@ -40,6 +40,8 @@ unsigned VRT_r_obj_cacheable(const struct sess *);
 void VRT_l_obj_cacheable(const struct sess *, unsigned);
 double VRT_r_obj_ttl(const struct sess *);
 void VRT_l_obj_ttl(const struct sess *, double);
+double VRT_r_obj_prefetch(const struct sess *);
+void VRT_l_obj_prefetch(const struct sess *, double);
 double VRT_r_obj_lastuse(const struct sess *);
 const char * VRT_r_resp_proto(const struct sess *);
 void VRT_l_resp_proto(const struct sess *, const char *, ...);
index b225ca2faa98cd77506327948ea1f300bdce12b7..6ea661e4702b7f566acc3c4c272237545c255df6 100644 (file)
@@ -156,6 +156,7 @@ parse_set(struct tokenlist *tl)
        case SIZE:
        case RATE:
        case TIME:
+       case RTIME:
        case FLOAT:
                if (tl->t->tok != '=')
                        Fb(tl, 0, "%s %c ", vp->rname, *tl->t->b);
@@ -171,6 +172,8 @@ parse_set(struct tokenlist *tl)
                case '=':
                        if (vp->fmt == TIME)
                                vcc_TimeVal(tl);
+                       else if (vp->fmt == RTIME)
+                               vcc_RTimeVal(tl);
                        else if (vp->fmt == SIZE)
                                vcc_SizeVal(tl);
                        else if (vp->fmt == RATE)
index 56f8407f033aa003e61810166ed9032b6f877ee1..c8977b5b4908b97116820815f554b685d801a3e7 100644 (file)
@@ -95,6 +95,7 @@ enum var_type {
        SIZE,
        RATE,
        TIME,
+       RTIME,
        STRING,
        IP,
        HOSTNAME,
@@ -174,6 +175,7 @@ extern struct var vcc_vars[];
 /* vcc_parse.c */
 void vcc_Parse(struct tokenlist *tl);
 void vcc_RateVal(struct tokenlist *tl);
+void vcc_RTimeVal(struct tokenlist *tl);
 void vcc_TimeVal(struct tokenlist *tl);
 void vcc_SizeVal(struct tokenlist *tl);
 unsigned vcc_UintVal(struct tokenlist *tl);
index 21d68c15ee94676fc863f7c24ea27f696d91e2f8..638f89f3ada95588bd26036849499e0c5bf6cb4f 100644 (file)
@@ -374,6 +374,7 @@ vcl_output_lang_h(struct vsb *sb)
        vsb_cat(sb, "   vcl_func_f      *hit_func;\n");
        vsb_cat(sb, "   vcl_func_f      *fetch_func;\n");
        vsb_cat(sb, "   vcl_func_f      *deliver_func;\n");
+       vsb_cat(sb, "   vcl_func_f      *prefetch_func;\n");
        vsb_cat(sb, "   vcl_func_f      *timeout_func;\n");
        vsb_cat(sb, "   vcl_func_f      *discard_func;\n");
        vsb_cat(sb, "};\n");
@@ -551,6 +552,8 @@ vcl_output_lang_h(struct vsb *sb)
        vsb_cat(sb, "void VRT_l_obj_cacheable(const struct sess *, unsigned);\n");
        vsb_cat(sb, "double VRT_r_obj_ttl(const struct sess *);\n");
        vsb_cat(sb, "void VRT_l_obj_ttl(const struct sess *, double);\n");
+       vsb_cat(sb, "double VRT_r_obj_prefetch(const struct sess *);\n");
+       vsb_cat(sb, "void VRT_l_obj_prefetch(const struct sess *, double);\n");
        vsb_cat(sb, "double VRT_r_obj_lastuse(const struct sess *);\n");
        vsb_cat(sb, "const char * VRT_r_resp_proto(const struct sess *);\n");
        vsb_cat(sb, "void VRT_l_resp_proto(const struct sess *, const char *, ...);\n");
index 578d70dbe973a97fa1d25bd32fdaae8a787acb63..71bb8265282c75ff2823cb671631bf29a97e7025 100755 (executable)
@@ -42,6 +42,7 @@ set methods {
        {hit            {error restart pass deliver}}
        {fetch          {error restart pass insert}}
        {deliver        {error restart deliver}}
+       {prefetch       {fetch pass}}
        {timeout        {fetch discard}}
        {discard        {discard keep}}
 }
index 669d478fc8238683612fd1f416a5dbab0fa3ccf7..1e88b93f8d7389720c838f7c2f65316dd0c17edd 100755 (executable)
@@ -157,6 +157,11 @@ set spobj {
                {                         hit fetch         discard timeout}
                "const struct sess *"
        }
+       { obj.prefetch
+               RW RTIME
+               { fetch prefetch }
+               "const struct sess *"
+       }
        { obj.lastuse
                RO TIME
                {                         hit fetch deliver discard timeout}
@@ -205,6 +210,7 @@ set tt(STRING)              "const char *"
 set tt(BOOL)           "unsigned"
 set tt(BACKEND)                "struct backend *"
 set tt(TIME)           "double"
+set tt(RTIME)          "double"
 set tt(INT)            "int"
 set tt(HDR_RESP)       "const char *"
 set tt(HDR_OBJ)                "const char *"
index 6ea90a03bb16db31703af4e81cd77b828243f15d..a89e6853f072753a4bcc346ebd6b7967d6107ca2 100644 (file)
@@ -182,6 +182,13 @@ struct var vcc_vars[] = {
            0,
            VCL_MET_HIT | VCL_MET_FETCH | VCL_MET_DISCARD | VCL_MET_TIMEOUT
        },
+       { "obj.prefetch", RTIME, 12,
+           "VRT_r_obj_prefetch(sp)",
+           "VRT_l_obj_prefetch(sp, ",
+           V_RW,
+           0,
+           VCL_MET_FETCH | VCL_MET_PREFETCH
+       },
        { "obj.lastuse", TIME, 11,
            "VRT_r_obj_lastuse(sp)",
            NULL,
index cd9fe7211302fe7bdb1d2eea81cc59d7e32c221d..e601a98b02fb3ea288ba8bc54eebc2a288f3b5d0 100644 (file)
@@ -183,6 +183,23 @@ vcc_DoubleVal(struct tokenlist *tl)
 
 /*--------------------------------------------------------------------*/
 
+void
+vcc_RTimeVal(struct tokenlist *tl)
+{
+       double v, sc;
+       int sign = 1;
+
+       if (tl->t->tok == '-') {
+               sign *= -1;
+               vcc_NextToken(tl);
+       }
+       v = vcc_DoubleVal(tl);
+       ERRCHK(tl);
+       ExpectErr(tl, ID);
+       sc = TimeUnit(tl);
+       Fb(tl, 0, "(%d * %g * %g)", sign, v, sc);
+}
+
 void
 vcc_TimeVal(struct tokenlist *tl)
 {