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

Fix a brain-o in the backend identification string: We need to

explicitly and uniquely identify all backend stanzas because they
have individual metrics.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@2872 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent a1fb2a33
...@@ -45,10 +45,10 @@ struct sockaddr; ...@@ -45,10 +45,10 @@ struct sockaddr;
* A backend is a host+port somewhere on the network * A backend is a host+port somewhere on the network
*/ */
struct vrt_backend { struct vrt_backend {
const char *portname; char *portname;
const char *hostname; char *hostname;
const char *vcl_name; char *vcl_name;
const char *ident; char *ident;
double connect_timeout; double connect_timeout;
}; };
......
...@@ -72,16 +72,14 @@ CheckHostPort(const char *host, const char *port) ...@@ -72,16 +72,14 @@ CheckHostPort(const char *host, const char *port)
*/ */
static void static void
vcc_EmitBeIdent(struct vsb *v, const struct token *qual, int serial, const struct token *first, const struct token *last) vcc_EmitBeIdent(struct vsb *v, const struct token *name, const char *qual, int serial, const struct token *first, const struct token *last)
{ {
vsb_printf(v, "\t.ident ="); vsb_printf(v, "\t.ident =");
if (serial != 0 && qual != NULL) { AN(qual);
vsb_printf(v, "\n\t \"%.*s \"", PF(qual)); vsb_printf(v, "\n\t \"%s %.*s\"", qual, PF(name));
qual = VTAILQ_NEXT(qual, list); if (serial != 0)
vsb_printf(v, "\n\t \"%.*s \"", PF(qual)); vsb_printf(v, "\n\t \"[%d]\"", serial);
vsb_printf(v, "\n\t \":: %d :: \"", serial);
}
while (first != last) { while (first != last) {
if (first->dec != NULL) if (first->dec != NULL)
vsb_printf(v, "\n\t \"\\\"\" %.*s \"\\\" \"", vsb_printf(v, "\n\t \"\\\"\" %.*s \"\\\" \"",
...@@ -213,7 +211,7 @@ vcc_FieldsOk(struct tokenlist *tl, const struct fld_spec *fs) ...@@ -213,7 +211,7 @@ vcc_FieldsOk(struct tokenlist *tl, const struct fld_spec *fs)
*/ */
static void static void
vcc_ParseBackendHost(struct tokenlist *tl, int *nbh, const struct token *qual, int serial) vcc_ParseBackendHost(struct tokenlist *tl, int *nbh, const struct token *name, const char *qual, int serial)
{ {
struct token *t_field; struct token *t_field;
struct token *t_first; struct token *t_first;
...@@ -274,6 +272,7 @@ vcc_ParseBackendHost(struct tokenlist *tl, int *nbh, const struct token *qual, i ...@@ -274,6 +272,7 @@ vcc_ParseBackendHost(struct tokenlist *tl, int *nbh, const struct token *qual, i
t_host = tl->t; t_host = tl->t;
vcc_NextToken(tl); vcc_NextToken(tl);
} else if (vcc_IdIs(t_field, "port")) { } else if (vcc_IdIs(t_field, "port")) {
ExpectErr(tl, CSTR);
assert(tl->t->dec != NULL); assert(tl->t->dec != NULL);
t_port = tl->t; t_port = tl->t;
vcc_NextToken(tl); vcc_NextToken(tl);
...@@ -330,8 +329,8 @@ vcc_ParseBackendHost(struct tokenlist *tl, int *nbh, const struct token *qual, i ...@@ -330,8 +329,8 @@ vcc_ParseBackendHost(struct tokenlist *tl, int *nbh, const struct token *qual, i
} }
ExpectErr(tl, '}'); ExpectErr(tl, '}');
vcc_EmitBeIdent(tl->fh, qual, serial, t_first, tl->t); vcc_EmitBeIdent(tl->fh, name, qual, serial, t_first, tl->t);
Fh(tl, 0, "\t.vcl_name = \"%.*s", PF(qual)); Fh(tl, 0, "\t.vcl_name = \"%.*s", PF(name));
if (serial) if (serial)
Fh(tl, 0, "[%d]", serial); Fh(tl, 0, "[%d]", serial);
Fh(tl, 0, "\"\n};\n"); Fh(tl, 0, "\"\n};\n");
...@@ -356,7 +355,7 @@ vcc_ParseBackend(struct tokenlist *tl) ...@@ -356,7 +355,7 @@ vcc_ParseBackend(struct tokenlist *tl)
h->name = tl->t; h->name = tl->t;
vcc_NextToken(tl); vcc_NextToken(tl);
vcc_ParseBackendHost(tl, &nbh, h->name, 0); vcc_ParseBackendHost(tl, &nbh, h->name, "backend", 0);
ERRCHK(tl); ERRCHK(tl);
h->hnum = nbh; h->hnum = nbh;
...@@ -421,7 +420,8 @@ vcc_ParseRandomDirector(struct tokenlist *tl, struct token *t_dir) ...@@ -421,7 +420,8 @@ vcc_ParseRandomDirector(struct tokenlist *tl, struct token *t_dir)
vcc_IsField(tl, &t_field, fs); vcc_IsField(tl, &t_field, fs);
ERRCHK(tl); ERRCHK(tl);
if (vcc_IdIs(t_field, "backend")) { if (vcc_IdIs(t_field, "backend")) {
vcc_ParseBackendHost(tl, &nbh, t_dir, nelem); vcc_ParseBackendHost(tl, &nbh,
t_dir, "random", nelem);
Fc(tl, 0, " .host = &bh_%d,", nbh); Fc(tl, 0, " .host = &bh_%d,", nbh);
ERRCHK(tl); ERRCHK(tl);
} else if (vcc_IdIs(t_field, "weight")) { } else if (vcc_IdIs(t_field, "weight")) {
......
...@@ -399,10 +399,10 @@ vcl_output_lang_h(struct vsb *sb) ...@@ -399,10 +399,10 @@ vcl_output_lang_h(struct vsb *sb)
vsb_cat(sb, " * A backend is a host+port somewhere on the network\n"); vsb_cat(sb, " * A backend is a host+port somewhere on the network\n");
vsb_cat(sb, " */\n"); vsb_cat(sb, " */\n");
vsb_cat(sb, "struct vrt_backend {\n"); vsb_cat(sb, "struct vrt_backend {\n");
vsb_cat(sb, " const char *portname;\n"); vsb_cat(sb, " char *portname;\n");
vsb_cat(sb, " const char *hostname;\n"); vsb_cat(sb, " char *hostname;\n");
vsb_cat(sb, " const char *vcl_name;\n"); vsb_cat(sb, " char *vcl_name;\n");
vsb_cat(sb, " const char *ident;\n"); vsb_cat(sb, " char *ident;\n");
vsb_cat(sb, " double connect_timeout;\n"); vsb_cat(sb, " double connect_timeout;\n");
vsb_cat(sb, "};\n"); vsb_cat(sb, "};\n");
vsb_cat(sb, "\n"); vsb_cat(sb, "\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