r4982 - trunk/varnish-cache/lib/libvcl

phk at varnish-cache.org phk at varnish-cache.org
Tue Jun 22 14:10:45 CEST 2010


Author: phk
Date: 2010-06-22 14:10:45 +0200 (Tue, 22 Jun 2010)
New Revision: 4982

Modified:
   trunk/varnish-cache/lib/libvcl/vcc_backend.c
   trunk/varnish-cache/lib/libvcl/vcc_compile.c
   trunk/varnish-cache/lib/libvcl/vcc_compile.h
Log:
If there is a backend or director named "default", make that the default,
otherwise use the first backend or director we find as default.



Modified: trunk/varnish-cache/lib/libvcl/vcc_backend.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_backend.c	2010-06-22 07:37:19 UTC (rev 4981)
+++ trunk/varnish-cache/lib/libvcl/vcc_backend.c	2010-06-22 12:10:45 UTC (rev 4982)
@@ -725,15 +725,9 @@
 		return;
 	}
 
-	if (isfirst == 1) {
-		/*
-		 * If this is the first backend|director explicitly
-		 * defined, use it as default backend.
-		 */
-		Fi(tl, 0,
-		    "\tVCL_conf.director[0] = VCL_conf.director[%d];\n",
-		    tl->ndirector - 1);
-		vcc_AddRef(tl, tl->t_dir, R_BACKEND);
+	if (isfirst == 1 || vcc_IdIs(tl->t_dir, "default")) {
+		tl->defaultdir = tl->ndirector - 1;
+		tl->t_defaultdir = tl->t_dir;
 	}
 
 	tl->t_policy = NULL;

Modified: trunk/varnish-cache/lib/libvcl/vcc_compile.c
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_compile.c	2010-06-22 07:37:19 UTC (rev 4981)
+++ trunk/varnish-cache/lib/libvcl/vcc_compile.c	2010-06-22 12:10:45 UTC (rev 4982)
@@ -589,6 +589,11 @@
 		return (vcc_DestroyTokenList(tl, NULL));
 	}
 
+	/* Configure the default director */
+	Fi(tl, 0, "\tVCL_conf.director[0] = VCL_conf.director[%d];\n",
+	    tl->defaultdir);
+	vcc_AddRef(tl, tl->t_defaultdir, R_BACKEND);
+
 	/* Check for orphans */
 	if (vcc_CheckReferences(tl))
 		return (vcc_DestroyTokenList(tl, NULL));

Modified: trunk/varnish-cache/lib/libvcl/vcc_compile.h
===================================================================
--- trunk/varnish-cache/lib/libvcl/vcc_compile.h	2010-06-22 07:37:19 UTC (rev 4981)
+++ trunk/varnish-cache/lib/libvcl/vcc_compile.h	2010-06-22 12:10:45 UTC (rev 4982)
@@ -88,6 +88,8 @@
 
 	VTAILQ_HEAD(, acl_e)	acl;
 
+	int			defaultdir;
+	struct token		*t_defaultdir;
 	struct token		*t_dir;
 	struct token		*t_policy;
 




More information about the varnish-commit mailing list