r2872 - in trunk/varnish-cache: include lib/libvcl
phk at projects.linpro.no
phk at projects.linpro.no
Tue Jul 1 21:23:56 CEST 2008
Author: phk
Date: 2008-07-01 21:23:56 +0200 (Tue, 01 Jul 2008)
New Revision: 2872
Modified:
trunk/varnish-cache/include/vrt.h
trunk/varnish-cache/lib/libvcl/vcc_backend.c
trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
Log:
Fix a brain-o in the backend identification string: We need to
explicitly and uniquely identify all backend stanzas because they
have individual metrics.
Modified: trunk/varnish-cache/include/vrt.h
===================================================================
--- trunk/varnish-cache/include/vrt.h 2008-06-30 09:08:01 UTC (rev 2871)
+++ trunk/varnish-cache/include/vrt.h 2008-07-01 19:23:56 UTC (rev 2872)
@@ -45,10 +45,10 @@
* A backend is a host+port somewhere on the network
*/
struct vrt_backend {
- const char *portname;
- const char *hostname;
- const char *vcl_name;
- const char *ident;
+ char *portname;
+ char *hostname;
+ char *vcl_name;
+ char *ident;
double connect_timeout;
};
Modified: trunk/varnish-cache/lib/libvcl/vcc_backend.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_backend.c 2008-06-30 09:08:01 UTC (rev 2871)
+++ trunk/varnish-cache/lib/libvcl/vcc_backend.c 2008-07-01 19:23:56 UTC (rev 2872)
@@ -72,16 +72,14 @@
*/
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 =");
- if (serial != 0 && qual != NULL) {
- vsb_printf(v, "\n\t \"%.*s \"", PF(qual));
- qual = VTAILQ_NEXT(qual, list);
- vsb_printf(v, "\n\t \"%.*s \"", PF(qual));
- vsb_printf(v, "\n\t \":: %d :: \"", serial);
- }
+ AN(qual);
+ vsb_printf(v, "\n\t \"%s %.*s\"", qual, PF(name));
+ if (serial != 0)
+ vsb_printf(v, "\n\t \"[%d]\"", serial);
while (first != last) {
if (first->dec != NULL)
vsb_printf(v, "\n\t \"\\\"\" %.*s \"\\\" \"",
@@ -213,7 +211,7 @@
*/
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_first;
@@ -274,6 +272,7 @@
t_host = tl->t;
vcc_NextToken(tl);
} else if (vcc_IdIs(t_field, "port")) {
+ ExpectErr(tl, CSTR);
assert(tl->t->dec != NULL);
t_port = tl->t;
vcc_NextToken(tl);
@@ -330,8 +329,8 @@
}
ExpectErr(tl, '}');
- vcc_EmitBeIdent(tl->fh, qual, serial, t_first, tl->t);
- Fh(tl, 0, "\t.vcl_name = \"%.*s", PF(qual));
+ vcc_EmitBeIdent(tl->fh, name, qual, serial, t_first, tl->t);
+ Fh(tl, 0, "\t.vcl_name = \"%.*s", PF(name));
if (serial)
Fh(tl, 0, "[%d]", serial);
Fh(tl, 0, "\"\n};\n");
@@ -356,7 +355,7 @@
h->name = tl->t;
vcc_NextToken(tl);
- vcc_ParseBackendHost(tl, &nbh, h->name, 0);
+ vcc_ParseBackendHost(tl, &nbh, h->name, "backend", 0);
ERRCHK(tl);
h->hnum = nbh;
@@ -421,7 +420,8 @@
vcc_IsField(tl, &t_field, fs);
ERRCHK(tl);
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);
ERRCHK(tl);
} else if (vcc_IdIs(t_field, "weight")) {
Modified: trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c 2008-06-30 09:08:01 UTC (rev 2871)
+++ trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c 2008-07-01 19:23:56 UTC (rev 2872)
@@ -399,10 +399,10 @@
vsb_cat(sb, " * A backend is a host+port somewhere on the network\n");
vsb_cat(sb, " */\n");
vsb_cat(sb, "struct vrt_backend {\n");
- vsb_cat(sb, " const char *portname;\n");
- vsb_cat(sb, " const char *hostname;\n");
- vsb_cat(sb, " const char *vcl_name;\n");
- vsb_cat(sb, " const char *ident;\n");
+ vsb_cat(sb, " char *portname;\n");
+ vsb_cat(sb, " char *hostname;\n");
+ vsb_cat(sb, " char *vcl_name;\n");
+ vsb_cat(sb, " char *ident;\n");
vsb_cat(sb, " double connect_timeout;\n");
vsb_cat(sb, "};\n");
vsb_cat(sb, "\n");
More information about the varnish-commit
mailing list