r2440 - in trunk/varnish-cache: include lib/libvcl

phk at projects.linpro.no phk at projects.linpro.no
Thu Feb 7 10:52:28 CET 2008


Author: phk
Date: 2008-02-07 10:52:26 +0100 (Thu, 07 Feb 2008)
New Revision: 2440

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:
Remove ident string from directors, they are not recycled.

Add vcl_name to backend hosts.  Simple backends get the obvious
name.  Directors inlined backend hosts gets the directors name
with an array suffix, for instance "b1[1]".



Modified: trunk/varnish-cache/include/vrt.h
===================================================================
--- trunk/varnish-cache/include/vrt.h	2008-02-07 09:33:30 UTC (rev 2439)
+++ trunk/varnish-cache/include/vrt.h	2008-02-07 09:52:26 UTC (rev 2440)
@@ -47,6 +47,7 @@
 struct vrt_backend {
 	const char	*portname;
 	const char	*hostname;
+	const char	*vcl_name;
 	const char	*ident;
 };
 
@@ -55,7 +56,6 @@
  */
 
 struct vrt_dir_simple {
-	const char				*ident;
 	const char				*name;
 	const struct vrt_backend		*host;
 };
@@ -70,7 +70,6 @@
 };
 
 struct vrt_dir_random {
-	const char 				*ident;
 	const char 				*name;
 	unsigned 				nmember;
 	const struct vrt_dir_random_entry	*members;

Modified: trunk/varnish-cache/lib/libvcl/vcc_backend.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_backend.c	2008-02-07 09:33:30 UTC (rev 2439)
+++ trunk/varnish-cache/lib/libvcl/vcc_backend.c	2008-02-07 09:52:26 UTC (rev 2440)
@@ -74,7 +74,7 @@
 {
 
 	vsb_printf(v, "\t.ident =");
-	if (qual != NULL) {
+	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));
@@ -322,7 +322,10 @@
 
 	ExpectErr(tl, '}');
 	vcc_EmitBeIdent(tl->fh, qual, serial, t_first, tl->t);
-	Fh(tl, 0, "};\n");
+	Fh(tl, 0, "\t.vcl_name = \"%.*s", PF(qual));
+	if (serial)
+		Fh(tl, 0, "[%d]", serial);
+	Fh(tl, 0, "\"\n};\n");
 	vcc_NextToken(tl);
 }
 
@@ -333,12 +336,10 @@
 void
 vcc_ParseBackend(struct tokenlist *tl)
 {
-	struct token *t_first;
 	struct host *h;
 	int nbh;
 
 	h = TlAlloc(tl, sizeof *h);
-	t_first = tl->t;		/* T_BACKEND */
 
 	vcc_NextToken(tl);
 
@@ -346,7 +347,7 @@
 	h->name = tl->t;
 	vcc_NextToken(tl);
 
-	vcc_ParseBackendHost(tl, &nbh, NULL, 0);
+	vcc_ParseBackendHost(tl, &nbh, h->name, 0);
 	ERRCHK(tl);
 
 	h->hnum = nbh;
@@ -367,7 +368,6 @@
 	    PF(h->name));
 	Fc(tl, 0, "\t.name = \"%.*s\",\n", PF(h->name));
 	Fc(tl, 0, "\t.host = &bh_%d,\n", nbh);
-	vcc_EmitBeIdent(tl->fc, NULL, 0, t_first, tl->t);
 	Fc(tl, 0, "};\n");
 
 	tl->nbackend++;
@@ -378,7 +378,7 @@
  */
 
 static void
-vcc_ParseRandomDirector(struct tokenlist *tl, const struct token *t_first, struct token *t_dir)
+vcc_ParseRandomDirector(struct tokenlist *tl, struct token *t_dir)
 {
 	struct token *t_field;
 	int nbh, nelem;
@@ -437,7 +437,6 @@
 	Fc(tl, 0, "\t.name = \"%.*s\",\n", PF(t_dir));
 	Fc(tl, 0, "\t.nmember = %d,\n", nelem);
 	Fc(tl, 0, "\t.members = vdre_%.*s,\n", PF(t_dir));
-	vcc_EmitBeIdent(tl->fc, NULL, 0, t_first, tl->t);
 	Fc(tl, 0, "};\n");
 	vcc_NextToken(tl);
 	Fi(tl, 0,
@@ -464,7 +463,7 @@
 
 	ExpectErr(tl, ID);		/* ID: policy */
 	if (vcc_IdIs(tl->t, "random")) 
-		vcc_ParseRandomDirector(tl, t_first, t_dir);
+		vcc_ParseRandomDirector(tl, t_dir);
 	else {
 		vsb_printf(tl->sb, "Unknown director policy: ");
 		vcc_ErrToken(tl, tl->t);

Modified: trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c	2008-02-07 09:33:30 UTC (rev 2439)
+++ trunk/varnish-cache/lib/libvcl/vcc_fixed_token.c	2008-02-07 09:52:26 UTC (rev 2440)
@@ -400,6 +400,7 @@
 	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, "};\n");
 	vsb_cat(sb, "\n");
@@ -408,7 +409,6 @@
 	vsb_cat(sb, " */\n");
 	vsb_cat(sb, "\n");
 	vsb_cat(sb, "struct vrt_dir_simple {\n");
-	vsb_cat(sb, "	const char				*ident;\n");
 	vsb_cat(sb, "	const char				*name;\n");
 	vsb_cat(sb, "	const struct vrt_backend		*host;\n");
 	vsb_cat(sb, "};\n");
@@ -423,7 +423,6 @@
 	vsb_cat(sb, "};\n");
 	vsb_cat(sb, "\n");
 	vsb_cat(sb, "struct vrt_dir_random {\n");
-	vsb_cat(sb, "	const char 				*ident;\n");
 	vsb_cat(sb, "	const char 				*name;\n");
 	vsb_cat(sb, "	unsigned 				nmember;\n");
 	vsb_cat(sb, "	const struct vrt_dir_random_entry	*members;\n");




More information about the varnish-commit mailing list