Commit 91d8021c authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Add a ".initial" property to backend probe specifications.

This is the number of good probes we pretend to have already seen when
we start up, in order to speed up getting healthy backends.

The default value is one less than the .threshold, so the backend
will be set healthy if it manages to respond correctly to the very 
first probe we send to it.

(A bit of this commit leaked in during r4184)



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4185 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent eebe8f2e
......@@ -306,9 +306,6 @@ vbp_has_poked(struct vbp_target *vt)
vt->backend->vcl_name, logmsg, bits,
vt->good, vt->probe.threshold, vt->probe.window,
vt->last, vt->avg, vt->resp_buf);
if (!vt->stop)
TIM_sleep(vt->probe.interval);
}
/*--------------------------------------------------------------------
......@@ -340,24 +337,20 @@ vbp_wrk_poll_backend(void *priv)
if (vt->probe.threshold == 0)
vt->probe.threshold = 3;
if (vt->probe.threshold == ~0)
if (vt->probe.threshold == ~0U)
vt->probe.initial = vt->probe.threshold - 1;
if (vt->probe.initial > vt->probe.threshold)
vt->probe.initial = vt->probe.threshold;
printf("Initial %u\n", vt->probe.initial);
printf("Probe(\"%s\", %g, %g)\n",
vt->req, vt->probe.timeout, vt->probe.interval);
if (0) {
for (u = 0; u < vt->probe.initial; u++) {
vbp_start_poke(vt);
vt->happy |= 1;
vbp_has_poked(vt);
}
}
while (!vt->stop) {
vbp_start_poke(vt);
......
......@@ -27,6 +27,7 @@ varnish v1 -vcl {
.host = "127.0.0.1"; .port = "9180";
.probe = {
.url = "/";
.initial = 0;
}
}
director foo random {
......
......@@ -18,6 +18,7 @@ varnish v1 -vcl {
.interval = 1s;
.window = 2;
.threshold = 1;
.initial = 0;
}
}
sub vcl_fetch {
......
......@@ -20,6 +20,7 @@ varnish v1 -vcl {
.interval = 1s;
.window = 3;
.threshold = 2;
.initial = 0;
}
}
......
......@@ -54,6 +54,7 @@ struct vrt_backend_probe {
double interval;
unsigned window;
unsigned threshold;
unsigned initial;
};
/*
......
......@@ -341,7 +341,8 @@ vcc_ParseProbe(struct tokenlist *tl)
struct fld_spec *fs;
struct token *t_field;
struct token *t_did = NULL, *t_window = NULL, *t_threshold = NULL;
unsigned window, threshold;
struct token *t_initial = NULL;
unsigned window, threshold, initial;
fs = vcc_FldSpec(tl,
"?url",
......@@ -350,6 +351,7 @@ vcc_ParseProbe(struct tokenlist *tl)
"?interval",
"?window",
"?threshold",
"?initial",
NULL);
ExpectErr(tl, '{');
......@@ -357,6 +359,7 @@ vcc_ParseProbe(struct tokenlist *tl)
window = 0;
threshold = 0;
initial = 0;
Fb(tl, 0, "\t.probe = {\n");
while (tl->t->tok != '}') {
......@@ -397,6 +400,11 @@ vcc_ParseProbe(struct tokenlist *tl)
window = vcc_UintVal(tl);
vcc_NextToken(tl);
ERRCHK(tl);
} else if (vcc_IdIs(t_field, "initial")) {
t_initial = tl->t;
initial = vcc_UintVal(tl);
vcc_NextToken(tl);
ERRCHK(tl);
} else if (vcc_IdIs(t_field, "threshold")) {
t_threshold = tl->t;
threshold = vcc_UintVal(tl);
......@@ -442,8 +450,12 @@ vcc_ParseProbe(struct tokenlist *tl)
vcc_ErrWhere(tl, t_window);
}
Fb(tl, 0, "\t\t.window = %u,\n", window);
Fb(tl, 0, "\t\t.threshold = %u\n", threshold);
Fb(tl, 0, "\t\t.threshold = %u,\n", threshold);
}
if (t_initial != NULL)
Fb(tl, 0, "\t\t.initial = %u,\n", initial);
else
Fb(tl, 0, "\t\t.initial = ~0U,\n", initial);
Fb(tl, 0, "\t},\n");
ExpectErr(tl, '}');
vcc_NextToken(tl);
......
/*
* $Id: vcc_gen_fixed_token.tcl 4099 2009-06-08 21:40:48Z phk $
* $Id: vcc_gen_fixed_token.tcl 4100 2009-06-09 10:41:38Z phk $
*
* NB: This file is machine generated, DO NOT EDIT!
*
......@@ -159,8 +159,8 @@ vcl_output_lang_h(struct vsb *sb)
/* ../../include/vcl.h */
vsb_cat(sb, "/*\n * $Id: vcc_gen_fixed_token.tcl 4099 2009-06-08 21");
vsb_cat(sb, ":40:48Z phk $\n *\n * NB: This file is machine genera");
vsb_cat(sb, "/*\n * $Id: vcc_gen_fixed_token.tcl 4100 2009-06-09 10");
vsb_cat(sb, ":41:38Z phk $\n *\n * NB: This file is machine genera");
vsb_cat(sb, "ted, DO NOT EDIT!\n *\n * Edit and run vcc_gen_fixed_t");
vsb_cat(sb, "oken.tcl instead\n */\n\nstruct sess;\n");
vsb_cat(sb, "struct cli;\n\ntypedef void vcl_init_f(struct cli *);\n");
......@@ -242,12 +242,12 @@ vcl_output_lang_h(struct vsb *sb)
vsb_cat(sb, "\nstruct vrt_backend_probe {\n\tconst char\t*url;\n");
vsb_cat(sb, "\tconst char\t*request;\n\tdouble\t\ttimeout;\n");
vsb_cat(sb, "\tdouble\t\tinterval;\n\tunsigned\twindow;\n");
vsb_cat(sb, "\tunsigned\tthreshold;\n};\n\n/*\n");
vsb_cat(sb, " * A backend is a host+port somewhere on the network\n");
vsb_cat(sb, " */\nstruct vrt_backend {\n\tconst char\t\t\t*vcl_name");
vsb_cat(sb, ";\n\tconst char\t\t\t*ident;\n\n");
vsb_cat(sb, "\tconst char\t\t\t*hosthdr;\n\n");
vsb_cat(sb, "\tconst unsigned char\t\t*ipv4_sockaddr;\n");
vsb_cat(sb, "\tunsigned\tthreshold;\n\tunsigned\tinitial;\n");
vsb_cat(sb, "};\n\n/*\n * A backend is a host+port somewhere on the");
vsb_cat(sb, " network\n */\nstruct vrt_backend {\n");
vsb_cat(sb, "\tconst char\t\t\t*vcl_name;\n\tconst char\t\t\t*ident");
vsb_cat(sb, ";\n\n\tconst char\t\t\t*hosthdr;\n");
vsb_cat(sb, "\n\tconst unsigned char\t\t*ipv4_sockaddr;\n");
vsb_cat(sb, "\tconst unsigned char\t\t*ipv6_sockaddr;\n");
vsb_cat(sb, "\n\tdouble\t\t\t\tconnect_timeout;\n");
vsb_cat(sb, "\tdouble\t\t\t\tfirst_byte_timeout;\n");
......@@ -319,8 +319,8 @@ vcl_output_lang_h(struct vsb *sb)
/* ../../include/vrt_obj.h */
vsb_cat(sb, "/*\n * $Id: vcc_gen_obj.tcl 4066 2009-05-10 21:21:36Z ");
vsb_cat(sb, "sky $\n *\n * NB: This file is machine generated, DO ");
vsb_cat(sb, "/*\n * $Id: vcc_gen_obj.tcl 4099 2009-06-08 21:40:48Z ");
vsb_cat(sb, "phk $\n *\n * NB: This file is machine generated, DO ");
vsb_cat(sb, "NOT EDIT!\n *\n * Edit vcc_gen_obj.tcl instead\n");
vsb_cat(sb, " */\n\nstruct sockaddr * VRT_r_client_ip(const struct ");
vsb_cat(sb, "sess *);\nstruct sockaddr * VRT_r_server_ip(struct ses");
......
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