From fbd98dbbd2d31f759b26542ccfdfa032d0c841f9 Mon Sep 17 00:00:00 2001 From: phk Date: Fri, 21 Sep 2007 08:16:02 +0000 Subject: [PATCH] Move implicit reference to first backend to the xref code. Don't panic if no backend.port is specified. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@1975 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- varnish-cache/lib/libvcl/vcc_backend.c | 17 ++++------------- varnish-cache/lib/libvcl/vcc_xref.c | 4 ++++ 2 files changed, 8 insertions(+), 13 deletions(-) diff --git a/varnish-cache/lib/libvcl/vcc_backend.c b/varnish-cache/lib/libvcl/vcc_backend.c index 75e58fa6..b770836d 100644 --- a/varnish-cache/lib/libvcl/vcc_backend.c +++ b/varnish-cache/lib/libvcl/vcc_backend.c @@ -71,12 +71,6 @@ vcc_ParseSimpleBackend(struct tokenlist *tl) ExpectErr(tl, ID); t_be = tl->t; vcc_AddDef(tl, tl->t, R_BACKEND); - /* - * The first backend is always referenced because that is the default - * at the beginning of vcl_recv - */ - if (tl->nbackend == 0) - vcc_AddRef(tl, tl->t, R_BACKEND); /* In the compiled vcl we use these macros to refer to backends */ Fh(tl, 1, "#define VGC_backend_%.*s (VCL_conf.backend[%d])\n", @@ -153,7 +147,10 @@ vcc_ParseSimpleBackend(struct tokenlist *tl) Fc(tl, 0, "\nstatic struct vrt_simple_backend sbe_%.*s = {\n", PF(t_be)); Fc(tl, 0, "\t.name = \"%.*s\",\n", PF(t_be)); - Fc(tl, 0, "\t.port = %.*s,\n", PF(t_port)); + if (t_port != NULL) + Fc(tl, 0, "\t.port = %.*s,\n", PF(t_port)); + else + Fc(tl, 0, "\t.port = \"http\",\n"); Fc(tl, 0, "\t.host = %.*s,\n", PF(t_host)); Fc(tl, 0, "};\n"); Fi(tl, 0, "\tVRT_init_simple_backend(&VGC_backend_%.*s , &sbe_%.*s);\n", @@ -180,12 +177,6 @@ vcc_ParseBalancedBackend(struct tokenlist *tl) ExpectErr(tl, ID); t_be = tl->t; vcc_AddDef(tl, tl->t, R_BACKEND); - /* - * The first backend is always referenced because that is the default - * at the beginning of vcl_recv - */ - if (tl->nbackend == 0) - vcc_AddRef(tl, tl->t, R_BACKEND); /* In the compiled vcl we use these macros to refer to backends */ Fh(tl, 1, "#define VGC_backend_%.*s (VCL_conf.backend[%d])\n", diff --git a/varnish-cache/lib/libvcl/vcc_xref.c b/varnish-cache/lib/libvcl/vcc_xref.c index 83821bf1..6755b6e3 100644 --- a/varnish-cache/lib/libvcl/vcc_xref.c +++ b/varnish-cache/lib/libvcl/vcc_xref.c @@ -139,6 +139,10 @@ vcc_AddDef(struct tokenlist *tl, struct token *t, enum ref_type type) } r->defcnt++; r->name = t; + + /* The first backend is the default and thus has an implicit ref */ + if (type == R_BACKEND && tl->nbackend == 0) + r->refcnt++; } /*--------------------------------------------------------------------*/ -- 2.39.5