Commit e8dae502 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Emit probe-specs as separate free-standing structs, and point

to them from backend specs.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4984 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent fd141417
...@@ -251,7 +251,7 @@ VBE_AddBackend(struct cli *cli, const struct vrt_backend *vb) ...@@ -251,7 +251,7 @@ VBE_AddBackend(struct cli *cli, const struct vrt_backend *vb)
assert(b->ipv4 != NULL || b->ipv6 != NULL); assert(b->ipv4 != NULL || b->ipv6 != NULL);
VBP_Start(b, &vb->probe); VBP_Start(b, vb->probe);
VTAILQ_INSERT_TAIL(&backends, b, list); VTAILQ_INSERT_TAIL(&backends, b, list);
VSC_main->n_backend++; VSC_main->n_backend++;
return (b); return (b);
......
...@@ -424,14 +424,13 @@ VBP_Start(struct backend *b, struct vrt_backend_probe const *p) ...@@ -424,14 +424,13 @@ VBP_Start(struct backend *b, struct vrt_backend_probe const *p)
ASSERT_CLI(); ASSERT_CLI();
ALLOC_OBJ(vt, VBP_TARGET_MAGIC); if (p == NULL) {
AN(vt);
if (!memcmp(&vt->probe, p, sizeof *p)) {
FREE_OBJ(vt);
/* No probe defined for this backend, set it healthy */
b->healthy = 1; b->healthy = 1;
return; return;
} }
ALLOC_OBJ(vt, VBP_TARGET_MAGIC);
AN(vt);
vt->backend = b; vt->backend = b;
vt->probe = *p; vt->probe = *p;
......
...@@ -74,7 +74,7 @@ struct vrt_backend { ...@@ -74,7 +74,7 @@ struct vrt_backend {
double between_bytes_timeout; double between_bytes_timeout;
unsigned max_connections; unsigned max_connections;
unsigned saintmode_threshold; unsigned saintmode_threshold;
struct vrt_backend_probe probe; const struct vrt_backend_probe *probe;
}; };
/* /*
......
...@@ -228,11 +228,9 @@ vcc_ProbeRedef(struct tokenlist *tl, struct token **t_did, ...@@ -228,11 +228,9 @@ vcc_ProbeRedef(struct tokenlist *tl, struct token **t_did,
/* .url and .request are mutually exclusive */ /* .url and .request are mutually exclusive */
if (*t_did != NULL) { if (*t_did != NULL) {
vsb_printf(tl->sb, vsb_printf(tl->sb, "Probe request redefinition at:\n");
"Probe request redefinition at:\n");
vcc_ErrWhere(tl, t_field); vcc_ErrWhere(tl, t_field);
vsb_printf(tl->sb, vsb_printf(tl->sb, "Previous definition:\n");
"Previous definition:\n");
vcc_ErrWhere(tl, *t_did); vcc_ErrWhere(tl, *t_did);
return; return;
} }
...@@ -240,7 +238,7 @@ vcc_ProbeRedef(struct tokenlist *tl, struct token **t_did, ...@@ -240,7 +238,7 @@ vcc_ProbeRedef(struct tokenlist *tl, struct token **t_did,
} }
static void static void
vcc_ParseProbe(struct tokenlist *tl) vcc_ParseProbeSpec(struct tokenlist *tl)
{ {
struct fld_spec *fs; struct fld_spec *fs;
struct token *t_field; struct token *t_field;
...@@ -266,7 +264,8 @@ vcc_ParseProbe(struct tokenlist *tl) ...@@ -266,7 +264,8 @@ vcc_ParseProbe(struct tokenlist *tl)
threshold = 0; threshold = 0;
initial = 0; initial = 0;
status = 0; status = 0;
Fb(tl, 0, "\t.probe = {\n"); Fh(tl, 0, "static const struct vrt_backend_probe vgc_probe_%d = {\n",
tl->nprobe++);
while (tl->t->tok != '}') { while (tl->t->tok != '}') {
vcc_IsField(tl, &t_field, fs); vcc_IsField(tl, &t_field, fs);
...@@ -275,32 +274,32 @@ vcc_ParseProbe(struct tokenlist *tl) ...@@ -275,32 +274,32 @@ vcc_ParseProbe(struct tokenlist *tl)
vcc_ProbeRedef(tl, &t_did, t_field); vcc_ProbeRedef(tl, &t_did, t_field);
ERRCHK(tl); ERRCHK(tl);
ExpectErr(tl, CSTR); ExpectErr(tl, CSTR);
Fb(tl, 0, "\t\t.url = "); Fh(tl, 0, "\t.url = ");
EncToken(tl->fb, tl->t); EncToken(tl->fh, tl->t);
Fb(tl, 0, ",\n"); Fh(tl, 0, ",\n");
vcc_NextToken(tl); vcc_NextToken(tl);
} else if (vcc_IdIs(t_field, "request")) { } else if (vcc_IdIs(t_field, "request")) {
vcc_ProbeRedef(tl, &t_did, t_field); vcc_ProbeRedef(tl, &t_did, t_field);
ERRCHK(tl); ERRCHK(tl);
ExpectErr(tl, CSTR); ExpectErr(tl, CSTR);
Fb(tl, 0, "\t\t.request =\n"); Fh(tl, 0, "\t.request =\n");
while (tl->t->tok == CSTR) { while (tl->t->tok == CSTR) {
Fb(tl, 0, "\t\t\t"); Fh(tl, 0, "\t\t");
EncToken(tl->fb, tl->t); EncToken(tl->fh, tl->t);
Fb(tl, 0, " \"\\r\\n\"\n"); Fh(tl, 0, " \"\\r\\n\"\n");
vcc_NextToken(tl); vcc_NextToken(tl);
} }
Fb(tl, 0, "\t\t\t\"\\r\\n\",\n"); Fh(tl, 0, "\t\t\"\\r\\n\",\n");
} else if (vcc_IdIs(t_field, "timeout")) { } else if (vcc_IdIs(t_field, "timeout")) {
Fb(tl, 0, "\t\t.timeout = "); Fh(tl, 0, "\t.timeout = ");
vcc_TimeVal(tl, &t); vcc_TimeVal(tl, &t);
ERRCHK(tl); ERRCHK(tl);
Fb(tl, 0, "%g,\n", t); Fh(tl, 0, "%g,\n", t);
} else if (vcc_IdIs(t_field, "interval")) { } else if (vcc_IdIs(t_field, "interval")) {
Fb(tl, 0, "\t\t.interval = "); Fh(tl, 0, "\t.interval = ");
vcc_TimeVal(tl, &t); vcc_TimeVal(tl, &t);
ERRCHK(tl); ERRCHK(tl);
Fb(tl, 0, "%g,\n", t); Fh(tl, 0, "%g,\n", t);
} else if (vcc_IdIs(t_field, "window")) { } else if (vcc_IdIs(t_field, "window")) {
t_window = tl->t; t_window = tl->t;
window = vcc_UintVal(tl); window = vcc_UintVal(tl);
...@@ -361,16 +360,16 @@ vcc_ParseProbe(struct tokenlist *tl) ...@@ -361,16 +360,16 @@ vcc_ParseProbe(struct tokenlist *tl)
AN(t_window); AN(t_window);
vcc_ErrWhere(tl, t_window); vcc_ErrWhere(tl, t_window);
} }
Fb(tl, 0, "\t\t.window = %u,\n", window); Fh(tl, 0, "\t.window = %u,\n", window);
Fb(tl, 0, "\t\t.threshold = %u,\n", threshold); Fh(tl, 0, "\t.threshold = %u,\n", threshold);
} }
if (t_initial != NULL) if (t_initial != NULL)
Fb(tl, 0, "\t\t.initial = %u,\n", initial); Fh(tl, 0, "\t.initial = %u,\n", initial);
else else
Fb(tl, 0, "\t\t.initial = ~0U,\n", initial); Fh(tl, 0, "\t.initial = ~0U,\n", initial);
if (status > 0) if (status > 0)
Fb(tl, 0, "\t\t.exp_status = %u,\n", status); Fh(tl, 0, "\t.exp_status = %u,\n", status);
Fb(tl, 0, "\t},\n"); Fh(tl, 0, "};\n");
SkipToken(tl, '}'); SkipToken(tl, '}');
} }
...@@ -496,8 +495,9 @@ vcc_ParseHostDef(struct tokenlist *tl, int serial, const char *vgcname) ...@@ -496,8 +495,9 @@ vcc_ParseHostDef(struct tokenlist *tl, int serial, const char *vgcname)
ERRCHK(tl); ERRCHK(tl);
saint = u; saint = u;
SkipToken(tl, ';'); SkipToken(tl, ';');
} else if (vcc_IdIs(t_field, "probe")) { } else if (vcc_IdIs(t_field, "probe") && tl->t->tok == '{') {
vcc_ParseProbe(tl); Fb(tl, 0, "\t.probe = &vgc_probe_%d,\n", tl->nprobe);
vcc_ParseProbeSpec(tl);
ERRCHK(tl); ERRCHK(tl);
} else { } else {
ErrInternal(tl); ErrInternal(tl);
......
...@@ -88,6 +88,8 @@ struct tokenlist { ...@@ -88,6 +88,8 @@ struct tokenlist {
VTAILQ_HEAD(, acl_e) acl; VTAILQ_HEAD(, acl_e) acl;
int nprobe;
int defaultdir; int defaultdir;
struct token *t_defaultdir; struct token *t_defaultdir;
struct token *t_dir; struct token *t_dir;
......
...@@ -233,8 +233,8 @@ vcl_output_lang_h(struct vsb *sb) ...@@ -233,8 +233,8 @@ vcl_output_lang_h(struct vsb *sb)
"char\t\t*ipv6_sockaddr;\n\n\tdouble\t\t\t\tconnect_timeout;\n" "char\t\t*ipv6_sockaddr;\n\n\tdouble\t\t\t\tconnect_timeout;\n"
"\tdouble\t\t\t\tfirst_byte_timeout;\n\tdouble\t\t\t\tbetween_byt" "\tdouble\t\t\t\tfirst_byte_timeout;\n\tdouble\t\t\t\tbetween_byt"
"es_timeout;\n\tunsigned\t\t\tmax_connections;\n\tunsigned\t" "es_timeout;\n\tunsigned\t\t\tmax_connections;\n\tunsigned\t"
"\t\tsaintmode_threshold;\n\tstruct vrt_backend_probe\tprobe;\n" "\t\tsaintmode_threshold;\n\tconst struct vrt_backend_probe\t"
"};\n\n/*\n * A director with an unpredictable reply\n" "*probe;\n};\n\n/*\n * A director with an unpredictable reply\n"
" */\n\nstruct vrt_dir_random_entry {\n\tint\t\t\t\t\thost;\n" " */\n\nstruct vrt_dir_random_entry {\n\tint\t\t\t\t\thost;\n"
"\tdouble\t\t\t\t\tweight;\n};\n\nstruct vrt_dir_random {\n" "\tdouble\t\t\t\t\tweight;\n};\n\nstruct vrt_dir_random {\n"
"\tconst char\t\t\t\t*name;\n\tunsigned\t\t\t\tretries;\n" "\tconst char\t\t\t\t*name;\n\tunsigned\t\t\t\tretries;\n"
......
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