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;
};
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
#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
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 *, ...);
case SIZE:
case RATE:
case TIME:
+ case RTIME:
case FLOAT:
if (tl->t->tok != '=')
Fb(tl, 0, "%s %c ", vp->rname, *tl->t->b);
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)
SIZE,
RATE,
TIME,
+ RTIME,
STRING,
IP,
HOSTNAME,
/* 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);
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");
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");
{hit {error restart pass deliver}}
{fetch {error restart pass insert}}
{deliver {error restart deliver}}
+ {prefetch {fetch pass}}
{timeout {fetch discard}}
{discard {discard keep}}
}
{ 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}
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 *"
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,
/*--------------------------------------------------------------------*/
+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)
{