r4401 - trunk/varnish-cache/lib/libvcl

phk at projects.linpro.no phk at projects.linpro.no
Wed Dec 16 10:53:26 CET 2009


Author: phk
Date: 2009-12-16 10:53:25 +0100 (Wed, 16 Dec 2009)
New Revision: 4401

Modified:
   trunk/varnish-cache/lib/libvcl/vcc_action.c
   trunk/varnish-cache/lib/libvcl/vcc_backend.c
   trunk/varnish-cache/lib/libvcl/vcc_compile.c
   trunk/varnish-cache/lib/libvcl/vcc_dir_random.c
   trunk/varnish-cache/lib/libvcl/vcc_dir_round_robin.c
   trunk/varnish-cache/lib/libvcl/vcc_parse.c
Log:
Refer to directors by integer index instead of pointer.



Modified: trunk/varnish-cache/lib/libvcl/vcc_action.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_action.c	2009-12-16 09:26:03 UTC (rev 4400)
+++ trunk/varnish-cache/lib/libvcl/vcc_action.c	2009-12-16 09:53:25 UTC (rev 4401)
@@ -251,7 +251,7 @@
 		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;

Modified: trunk/varnish-cache/lib/libvcl/vcc_backend.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_backend.c	2009-12-16 09:26:03 UTC (rev 4400)
+++ trunk/varnish-cache/lib/libvcl/vcc_backend.c	2009-12-16 09:53:25 UTC (rev 4401)
@@ -501,8 +501,7 @@
 	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 @@
 	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 @@
 	} 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 @@
 	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 @@
 		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++;

Modified: trunk/varnish-cache/lib/libvcl/vcc_compile.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_compile.c	2009-12-16 09:26:03 UTC (rev 4400)
+++ trunk/varnish-cache/lib/libvcl/vcc_compile.c	2009-12-16 09:53:25 UTC (rev 4401)
@@ -552,6 +552,9 @@
 	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++;

Modified: trunk/varnish-cache/lib/libvcl/vcc_dir_random.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_dir_random.c	2009-12-16 09:26:03 UTC (rev 4400)
+++ trunk/varnish-cache/lib/libvcl/vcc_dir_random.c	2009-12-16 09:53:25 UTC (rev 4401)
@@ -58,7 +58,7 @@
 	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 @@
 	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));
 }

Modified: trunk/varnish-cache/lib/libvcl/vcc_dir_round_robin.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_dir_round_robin.c	2009-12-16 09:26:03 UTC (rev 4400)
+++ trunk/varnish-cache/lib/libvcl/vcc_dir_round_robin.c	2009-12-16 09:53:25 UTC (rev 4401)
@@ -56,7 +56,7 @@
 	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 @@
 	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));
 }

Modified: trunk/varnish-cache/lib/libvcl/vcc_parse.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_parse.c	2009-12-16 09:26:03 UTC (rev 4400)
+++ trunk/varnish-cache/lib/libvcl/vcc_parse.c	2009-12-16 09:53:25 UTC (rev 4401)
@@ -322,7 +322,7 @@
 	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);
 }
 



More information about the varnish-commit mailing list