Commit 8ea1366c authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Refer to directors by integer index instead of pointer.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@4401 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 9609a75c
......@@ -251,7 +251,7 @@ parse_set(struct tokenlist *tl)
vcc_ExpectCid(tl);
ERRCHK(tl);
vcc_AddRef(tl, tl->t, R_BACKEND);
Fb(tl, 0, "VGC_backend__%.*s", PF(tl->t));
Fb(tl, 0, "VGCDIR(_%.*s)", PF(tl->t));
vcc_NextToken(tl);
Fb(tl, 0, ");\n");
break;
......
......@@ -501,8 +501,7 @@ vcc_ParseHostDef(struct tokenlist *tl, int *nbh, int serial,
struct vsb *vsb;
unsigned u;
Fh(tl, 1, "\n#define %s (VCL_conf.director[%d])\n",
vgcname, tl->ndirector);
Fh(tl, 1, "\n#define VGC_backend_%s %d\n", vgcname, tl->ndirector);
fs = vcc_FldSpec(tl,
"!host",
......@@ -677,9 +676,9 @@ vcc_ParseHostDef(struct tokenlist *tl, int *nbh, int serial,
Fh(tl, 0, "%s", vsb_data(vsb));
vsb_delete(vsb);
Fi(tl, 0, "\tVRT_init_dir_simple(cli, &%s, &bh_%d);\n",
Fi(tl, 0, "\tVRT_init_dir_simple(cli, &VGCDIR(%s), &bh_%d);\n",
vgcname, *nbh);
Ff(tl, 0, "\tVRT_fini_dir(cli, %s);\n", vgcname);
Ff(tl, 0, "\tVRT_fini_dir(cli, VGCDIR(%s));\n", vgcname);
tl->ndirector++;
}
......@@ -722,7 +721,7 @@ vcc_ParseBackendHost(struct tokenlist *tl, int *nbh, int serial)
} else if (tl->t->tok == '{') {
t = tl->t;
sprintf(vgcname, "VGC_backend_%.*s_%d", PF(tl->t_dir), serial);
sprintf(vgcname, "%.*s_%d", PF(tl->t_dir), serial);
vcc_ParseHostDef(tl, nbh, serial, vgcname);
if (tl->err) {
......@@ -755,7 +754,7 @@ vcc_ParseSimpleDirector(struct tokenlist *tl)
h = TlAlloc(tl, sizeof *h);
h->name = tl->t_dir;
vcc_AddDef(tl, tl->t_dir, R_BACKEND);
sprintf(vgcname, "VGC_backend__%.*s", PF(h->name));
sprintf(vgcname, "_%.*s", PF(h->name));
h->vgcname = TlAlloc(tl, strlen(vgcname) + 1);
strcpy(h->vgcname, vgcname);
......@@ -797,8 +796,7 @@ vcc_ParseDirector(struct tokenlist *tl)
tl->t_policy = t_first;
vcc_ParseSimpleDirector(tl);
} else {
Fh(tl, 1,
"\n#define VGC_backend__%.*s (VCL_conf.director[%d])\n",
Fh(tl, 1, "\n#define VGC_backend__%.*s %d\n",
PF(tl->t_dir), tl->ndirector);
vcc_AddDef(tl, tl->t_dir, R_BACKEND);
tl->ndirector++;
......
......@@ -552,6 +552,9 @@ vcc_CompileSource(struct vsb *sb, struct source *sp)
Fh(tl, 0, "\n/* ---===### VCC generated below here ###===---*/\n");
Fh(tl, 0, "\nextern const struct VCL_conf VCL_conf;\n");
/* Macro for accessing directors */
Fh(tl, 0, "#define VGCDIR(n) VCL_conf.director[VGC_backend_##n]\n");
/* Register and lex the main source */
VTAILQ_INSERT_TAIL(&tl->sources, sp, list);
sp->idx = tl->nsources++;
......
......@@ -58,7 +58,7 @@ vcc_ParseRandomDirector(struct tokenlist *tl)
unsigned u, retries;
const char *first;
Ff(tl, 0, "\tVRT_fini_dir(cli, VGC_backend__%.*s);\n", PF(tl->t_dir));
Ff(tl, 0, "\tVRT_fini_dir(cli, VGCDIR(_%.*s));\n", PF(tl->t_dir));
fs = vcc_FldSpec(tl, "?retries", NULL);
......@@ -142,7 +142,6 @@ vcc_ParseRandomDirector(struct tokenlist *tl)
Fc(tl, 0, "\t.nmember = %d,\n", nelem);
Fc(tl, 0, "\t.members = vdre_%.*s,\n", PF(tl->t_dir));
Fc(tl, 0, "};\n");
Fi(tl, 0,
"\tVRT_init_dir_random(cli, &VGC_backend__%.*s , &vdr_%.*s);\n",
Fi(tl, 0, "\tVRT_init_dir_random(cli, &VGCDIR(_%.*s) , &vdr_%.*s);\n",
PF(tl->t_dir), PF(tl->t_dir));
}
......@@ -56,7 +56,7 @@ vcc_ParseRoundRobinDirector(struct tokenlist *tl)
struct fld_spec *fs;
const char *first;
Ff(tl, 0, "\tVRT_fini_dir(cli, VGC_backend__%.*s);\n", PF(tl->t_dir));
Ff(tl, 0, "\tVRT_fini_dir(cli, VGCDIR(_%.*s));\n", PF(tl->t_dir));
fs = vcc_FldSpec(tl, "!backend", NULL);
......@@ -104,6 +104,6 @@ vcc_ParseRoundRobinDirector(struct tokenlist *tl)
Fc(tl, 0, "\t.members = vdrre_%.*s,\n", PF(tl->t_dir));
Fc(tl, 0, "};\n");
Fi(tl, 0, "\tVRT_init_dir_round_robin("
"cli, &VGC_backend__%.*s , &vdrr_%.*s);\n",
"cli, &VGCDIR(_%.*s), &vdrr_%.*s);\n",
PF(tl->t_dir), PF(tl->t_dir));
}
......@@ -322,7 +322,7 @@ Cond_Backend(const struct var *vp, struct tokenlist *tl)
vcc_ExpectCid(tl);
ERRCHK(tl);
vcc_AddRef(tl, tl->t, R_BACKEND);
Fb(tl, 1, "VGC_backend__%.*s\n", PF(tl->t));
Fb(tl, 1, "VGCDIR(_%.*s)\n", PF(tl->t));
vcc_NextToken(tl);
}
......
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