r4394 - trunk/varnish-cache/lib/libvcl
phk at projects.linpro.no
phk at projects.linpro.no
Tue Dec 15 12:23:41 CET 2009
Author: phk
Date: 2009-12-15 12:23:41 +0100 (Tue, 15 Dec 2009)
New Revision: 4394
Modified:
trunk/varnish-cache/lib/libvcl/vcc_backend.c
trunk/varnish-cache/lib/libvcl/vcc_dir_random.c
trunk/varnish-cache/lib/libvcl/vcc_dir_round_robin.c
Log:
Make all anonymous backends have a simple director.
Modified: trunk/varnish-cache/lib/libvcl/vcc_backend.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_backend.c 2009-12-15 10:32:21 UTC (rev 4393)
+++ trunk/varnish-cache/lib/libvcl/vcc_backend.c 2009-12-15 11:23:41 UTC (rev 4394)
@@ -490,7 +490,7 @@
static void
vcc_ParseHostDef(struct tokenlist *tl, int *nbh, const struct token *name,
- const struct token *qual, int serial)
+ const struct token *qual, int serial, const char *vgcname)
{
struct token *t_field;
struct token *t_first;
@@ -503,6 +503,9 @@
struct vsb *vsb;
unsigned u;
+ Fh(tl, 1, "\n#define %s (VCL_conf.director[%d])\n",
+ vgcname, tl->ndirector);
+
fs = vcc_FldSpec(tl,
"!host",
"?port",
@@ -675,6 +678,11 @@
AZ(vsb_overflowed(vsb));
Fh(tl, 0, "%s", vsb_data(vsb));
vsb_delete(vsb);
+
+ Fi(tl, 0, "\tVRT_init_dir_simple(cli, &%s, &bh_%d);\n",
+ vgcname, *nbh);
+ Ff(tl, 0, "\tVRT_fini_dir(cli, %s);\n", vgcname);
+ tl->ndirector++;
}
/*--------------------------------------------------------------------
@@ -695,6 +703,7 @@
{
struct host *h;
struct token *t;
+ char vgcname[BUFSIZ];
if (tl->t->tok == ID) {
VTAILQ_FOREACH(h, &tl->hosts, list) {
@@ -715,7 +724,10 @@
*nbh = h->hnum;
} else if (tl->t->tok == '{') {
t = tl->t;
- vcc_ParseHostDef(tl, nbh, name, qual, serial);
+
+ sprintf(vgcname, "VGC_backend_%.*s_%d", PF(name), serial);
+
+ vcc_ParseHostDef(tl, nbh, name, qual, serial, vgcname);
if (tl->err) {
vsb_printf(tl->sb,
"\nIn backend host specification starting at:\n");
@@ -742,20 +754,17 @@
struct token *t_dir)
{
struct host *h;
+ char vgcname[BUFSIZ];
h = TlAlloc(tl, sizeof *h);
h->name = t_dir;
+ vcc_AddDef(tl, t_dir, R_BACKEND);
+ sprintf(vgcname, "VGC_backend__%.*s", PF(h->name));
- vcc_ParseHostDef(tl, &h->hnum, h->name, t_first, -1);
+ vcc_ParseHostDef(tl, &h->hnum, h->name, t_first, -1, vgcname);
ERRCHK(tl);
VTAILQ_INSERT_TAIL(&tl->hosts, h, list);
-
- Fi(tl, 0,
- "\tVRT_init_dir_simple(cli, &VGC_backend__%.*s , &bh_%d);\n",
- PF(h->name), h->hnum);
- Ff(tl, 0, "\tVRT_fini_dir(cli, VGC_backend__%.*s);\n", PF(h->name));
-
}
/*--------------------------------------------------------------------
@@ -785,14 +794,15 @@
t_dir = tl->t;
vcc_NextToken(tl);
- Fh(tl, 1, "\n#define VGC_backend__%.*s (VCL_conf.director[%d])\n",
- PF(t_dir), tl->ndirector);
- vcc_AddDef(tl, t_dir, R_BACKEND);
- tl->ndirector++;
if (vcc_IdIs(t_first, "backend")) {
vcc_ParseSimpleDirector(tl, t_first, t_dir);
} else {
+ Fh(tl, 1,
+ "\n#define VGC_backend__%.*s (VCL_conf.director[%d])\n",
+ PF(t_dir), tl->ndirector);
+ vcc_AddDef(tl, t_dir, R_BACKEND);
+ tl->ndirector++;
ExpectErr(tl, ID); /* ID: policy */
t_policy = tl->t;
vcc_NextToken(tl);
Modified: trunk/varnish-cache/lib/libvcl/vcc_dir_random.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_dir_random.c 2009-12-15 10:32:21 UTC (rev 4393)
+++ trunk/varnish-cache/lib/libvcl/vcc_dir_random.c 2009-12-15 11:23:41 UTC (rev 4394)
@@ -59,6 +59,8 @@
unsigned u, retries;
const char *first;
+ Ff(tl, 0, "\tVRT_fini_dir(cli, VGC_backend__%.*s);\n", PF(t_dir));
+
fs = vcc_FldSpec(tl, "?retries", NULL);
retries = 0;
@@ -145,5 +147,4 @@
Fi(tl, 0,
"\tVRT_init_dir_random(cli, &VGC_backend__%.*s , &vdr_%.*s);\n",
PF(t_dir), PF(t_dir));
- Ff(tl, 0, "\tVRT_fini_dir(cli, VGC_backend__%.*s);\n", PF(t_dir));
}
Modified: trunk/varnish-cache/lib/libvcl/vcc_dir_round_robin.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_dir_round_robin.c 2009-12-15 10:32:21 UTC (rev 4393)
+++ trunk/varnish-cache/lib/libvcl/vcc_dir_round_robin.c 2009-12-15 11:23:41 UTC (rev 4394)
@@ -57,6 +57,8 @@
struct fld_spec *fs;
const char *first;
+ Ff(tl, 0, "\tVRT_fini_dir(cli, VGC_backend__%.*s);\n", PF(t_dir));
+
fs = vcc_FldSpec(tl, "!backend", NULL);
Fc(tl, 0, "\nstatic const struct vrt_dir_round_robin_entry "
@@ -105,5 +107,4 @@
Fc(tl, 0, "};\n");
Fi(tl, 0, "\tVRT_init_dir_round_robin("
"cli, &VGC_backend__%.*s , &vdrr_%.*s);\n", PF(t_dir), PF(t_dir));
- Ff(tl, 0, "\tVRT_fini_dir(cli, VGC_backend__%.*s);\n", PF(t_dir));
}
More information about the varnish-commit
mailing list