From: phk Date: Thu, 7 Feb 2008 09:52:26 +0000 (+0000) Subject: Remove ident string from directors, they are not recycled. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d38ed955c7c05a354a035f9486657c9667ccff22;p=varnish 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]". git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2440 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/include/vrt.h b/varnish-cache/include/vrt.h index e6e4eabd..ea7a0f2b 100644 --- a/varnish-cache/include/vrt.h +++ b/varnish-cache/include/vrt.h @@ -47,6 +47,7 @@ struct sockaddr; struct vrt_backend { const char *portname; const char *hostname; + const char *vcl_name; const char *ident; }; @@ -55,7 +56,6 @@ struct vrt_backend { */ struct vrt_dir_simple { - const char *ident; const char *name; const struct vrt_backend *host; }; @@ -70,7 +70,6 @@ struct vrt_dir_random_entry { }; struct vrt_dir_random { - const char *ident; const char *name; unsigned nmember; const struct vrt_dir_random_entry *members; diff --git a/varnish-cache/lib/libvcl/vcc_backend.c b/varnish-cache/lib/libvcl/vcc_backend.c index afeb9383..84cef5cc 100644 --- a/varnish-cache/lib/libvcl/vcc_backend.c +++ b/varnish-cache/lib/libvcl/vcc_backend.c @@ -74,7 +74,7 @@ vcc_EmitBeIdent(struct vsb *v, const struct token *qual, int serial, const struc { 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 @@ vcc_ParseBackendHost(struct tokenlist *tl, int *nbh, const struct token *qual, i 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 @@ vcc_ParseBackendHost(struct tokenlist *tl, int *nbh, const struct token *qual, i 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 @@ vcc_ParseBackend(struct tokenlist *tl) 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 @@ vcc_ParseBackend(struct tokenlist *tl) 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 @@ vcc_ParseBackend(struct tokenlist *tl) */ 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 @@ vcc_ParseRandomDirector(struct tokenlist *tl, const struct token *t_first, struc 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 @@ vcc_ParseDirector(struct tokenlist *tl) 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); diff --git a/varnish-cache/lib/libvcl/vcc_fixed_token.c b/varnish-cache/lib/libvcl/vcc_fixed_token.c index 19f976e9..e69da52a 100644 --- a/varnish-cache/lib/libvcl/vcc_fixed_token.c +++ b/varnish-cache/lib/libvcl/vcc_fixed_token.c @@ -400,6 +400,7 @@ vcl_output_lang_h(struct vsb *sb) 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 @@ vcl_output_lang_h(struct vsb *sb) 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 @@ vcl_output_lang_h(struct vsb *sb) 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");