Commit bf17b9c3 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Move implicit reference to first backend to the xref code.

Don't panic if no backend.port is specified.



git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@1975 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent 6a4c8df0
......@@ -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",
......
......@@ -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++;
}
/*--------------------------------------------------------------------*/
......
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