r1975 - trunk/varnish-cache/lib/libvcl

phk at projects.linpro.no phk at projects.linpro.no
Fri Sep 21 10:16:02 CEST 2007


Author: phk
Date: 2007-09-21 10:16:02 +0200 (Fri, 21 Sep 2007)
New Revision: 1975

Modified:
   trunk/varnish-cache/lib/libvcl/vcc_backend.c
   trunk/varnish-cache/lib/libvcl/vcc_xref.c
Log:
Move implicit reference to first backend to the xref code.

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



Modified: trunk/varnish-cache/lib/libvcl/vcc_backend.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_backend.c	2007-09-20 22:27:25 UTC (rev 1974)
+++ trunk/varnish-cache/lib/libvcl/vcc_backend.c	2007-09-21 08:16:02 UTC (rev 1975)
@@ -71,12 +71,6 @@
 	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 @@
 	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 @@
 	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",

Modified: trunk/varnish-cache/lib/libvcl/vcc_xref.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_xref.c	2007-09-20 22:27:25 UTC (rev 1974)
+++ trunk/varnish-cache/lib/libvcl/vcc_xref.c	2007-09-21 08:16:02 UTC (rev 1975)
@@ -139,6 +139,10 @@
 	}
 	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++;
 }
 
 /*--------------------------------------------------------------------*/




More information about the varnish-commit mailing list