r5040 - in branches/2.1: . varnish-cache/bin/varnishd varnish-cache/bin/varnishtest/tests varnish-cache/include varnish-cache/lib/libvarnish varnish-cache/lib/libvcl

tfheen at varnish-cache.org tfheen at varnish-cache.org
Tue Jul 13 11:03:13 CEST 2010


Author: tfheen
Date: 2010-07-13 11:03:13 +0200 (Tue, 13 Jul 2010)
New Revision: 5040

Added:
   branches/2.1/varnish-cache/bin/varnishtest/tests/r00722.vtc
Modified:
   branches/2.1/
   branches/2.1/varnish-cache/bin/varnishd/cache_backend.h
   branches/2.1/varnish-cache/bin/varnishd/cache_backend_cfg.c
   branches/2.1/varnish-cache/bin/varnishd/vparam.h
   branches/2.1/varnish-cache/bin/varnishtest/tests/c00019.vtc
   branches/2.1/varnish-cache/bin/varnishtest/tests/r00325.vtc
   branches/2.1/varnish-cache/bin/varnishtest/tests/r00416.vtc
   branches/2.1/varnish-cache/bin/varnishtest/tests/v00011.vtc
   branches/2.1/varnish-cache/include/vct.h
   branches/2.1/varnish-cache/include/vev.h
   branches/2.1/varnish-cache/lib/libvarnish/tcp.c
   branches/2.1/varnish-cache/lib/libvarnish/vev.c
   branches/2.1/varnish-cache/lib/libvcl/vcc_backend.c
   branches/2.1/varnish-cache/lib/libvcl/vcc_compile.c
   branches/2.1/varnish-cache/lib/libvcl/vcc_dir_random.c
   branches/2.1/varnish-cache/lib/libvcl/vcc_xref.c
Log:
Merge r4967: Fix a problem in director teardown at vcl.discard time

We didn't create/destroy directors and backends in a consistent order,
and in some case we even destroyed directors more than once.

Always destroy in opposite order of creation (which follows VCL
source order).

Turn the bottom element of the array into (only) an indication
of which backend/director is the default.

Fixes:  #722




Property changes on: branches/2.1
___________________________________________________________________
Modified: svn:mergeinfo
   - /trunk:4637,4640,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4829,4842,4865-4868,4971,4973-4975,4977,4980-4981,4989
   + /trunk:4637,4640,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4829,4842,4865-4868,4967,4971,4973-4975,4977,4980-4981,4989


Property changes on: branches/2.1/varnish-cache/bin/varnishd/cache_backend.h
___________________________________________________________________
Modified: svn:mergeinfo
   - /trunk/varnish-cache/bin/varnishd/cache_backend.h:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4829,4842,4865-4868,4971,4973-4975,4977,4980-4981,4989
   + /trunk/varnish-cache/bin/varnishd/cache_backend.h:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4829,4842,4865-4868,4967,4971,4973-4975,4977,4980-4981,4989


Property changes on: branches/2.1/varnish-cache/bin/varnishd/cache_backend_cfg.c
___________________________________________________________________
Modified: svn:mergeinfo
   - /trunk/varnish-cache/bin/varnishd/cache_backend_cfg.c:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4829,4842,4865-4868,4971,4973-4975,4977,4980-4981,4989
   + /trunk/varnish-cache/bin/varnishd/cache_backend_cfg.c:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4829,4842,4865-4868,4967,4971,4973-4975,4977,4980-4981,4989


Property changes on: branches/2.1/varnish-cache/bin/varnishd/vparam.h
___________________________________________________________________
Modified: svn:mergeinfo
   - /trunk/varnish-cache/bin/varnishd/vparam.h:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4829,4842,4865-4868,4971,4973-4975,4977,4980-4981,4989
   + /trunk/varnish-cache/bin/varnishd/vparam.h:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4829,4842,4865-4868,4967,4971,4973-4975,4977,4980-4981,4989


Property changes on: branches/2.1/varnish-cache/bin/varnishtest/tests/c00019.vtc
___________________________________________________________________
Modified: svn:mergeinfo
   - /trunk/varnish-cache/bin/varnishtest/tests/c00019.vtc:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4829,4842,4865-4868,4971,4973-4975,4977,4980-4981,4989
   + /trunk/varnish-cache/bin/varnishtest/tests/c00019.vtc:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4829,4842,4865-4868,4967,4971,4973-4975,4977,4980-4981,4989


Property changes on: branches/2.1/varnish-cache/bin/varnishtest/tests/r00325.vtc
___________________________________________________________________
Modified: svn:mergeinfo
   - /trunk/varnish-cache/bin/varnishtest/tests/r00325.vtc:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4829,4842,4865-4868,4971,4973-4975,4977,4980-4981,4989
   + /trunk/varnish-cache/bin/varnishtest/tests/r00325.vtc:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4829,4842,4865-4868,4967,4971,4973-4975,4977,4980-4981,4989


Property changes on: branches/2.1/varnish-cache/bin/varnishtest/tests/r00416.vtc
___________________________________________________________________
Modified: svn:mergeinfo
   - /trunk/varnish-cache/bin/varnishtest/tests/r00416.vtc:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4829,4842,4865-4868,4971,4973-4975,4977,4980-4981,4989
   + /trunk/varnish-cache/bin/varnishtest/tests/r00416.vtc:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4829,4842,4865-4868,4967,4971,4973-4975,4977,4980-4981,4989

Copied: branches/2.1/varnish-cache/bin/varnishtest/tests/r00722.vtc (from rev 4967, trunk/varnish-cache/bin/varnishtest/tests/r00722.vtc)
===================================================================
--- branches/2.1/varnish-cache/bin/varnishtest/tests/r00722.vtc	                        (rev 0)
+++ branches/2.1/varnish-cache/bin/varnishtest/tests/r00722.vtc	2010-07-13 09:03:13 UTC (rev 5040)
@@ -0,0 +1,31 @@
+# $Id$
+
+test "Director cleanup fails on vcl.discard"
+
+server s1 {
+	rxreq
+	txresp
+} -start
+
+varnish v1 -vcl+backend {
+	director foo random {
+		{ .backend = s1; .weight = 1; }
+		{ .backend = { .host = "${s1_addr}"; .port = "${s1_port}";} .weight =1; }
+		{ .backend = { .host = "${s1_addr}"; .port = "${s1_port}";} .weight =1; }
+	}
+	sub vcl_recv {
+		set req.backend = foo;
+	}
+} -start
+
+
+varnish v1 -vcl+backend { }
+
+varnish v1 -cliok "vcl.list"
+varnish v1 -cliok "vcl.discard vcl1"
+
+client c1 {
+	txreq
+	rxresp
+} -run
+


Property changes on: branches/2.1/varnish-cache/bin/varnishtest/tests/v00011.vtc
___________________________________________________________________
Modified: svn:mergeinfo
   - /trunk/varnish-cache/bin/varnishtest/tests/v00011.vtc:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4829,4842,4865-4868,4971,4973-4975,4977,4980-4981,4989
   + /trunk/varnish-cache/bin/varnishtest/tests/v00011.vtc:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4829,4842,4865-4868,4967,4971,4973-4975,4977,4980-4981,4989


Property changes on: branches/2.1/varnish-cache/include/vct.h
___________________________________________________________________
Modified: svn:mergeinfo
   - /trunk/varnish-cache/include/vct.h:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4829,4842,4865-4868,4971,4973-4975,4977,4980-4981,4989
   + /trunk/varnish-cache/include/vct.h:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4829,4842,4865-4868,4967,4971,4973-4975,4977,4980-4981,4989


Property changes on: branches/2.1/varnish-cache/include/vev.h
___________________________________________________________________
Modified: svn:mergeinfo
   - /trunk/varnish-cache/include/vev.h:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4829,4842,4865-4868,4971,4973-4975,4977,4980-4981,4989
   + /trunk/varnish-cache/include/vev.h:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4829,4842,4865-4868,4967,4971,4973-4975,4977,4980-4981,4989


Property changes on: branches/2.1/varnish-cache/lib/libvarnish/tcp.c
___________________________________________________________________
Modified: svn:mergeinfo
   - /trunk/varnish-cache/lib/libvarnish/tcp.c:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4829,4842,4865-4868,4971,4973-4975,4977,4980-4981,4989
   + /trunk/varnish-cache/lib/libvarnish/tcp.c:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4829,4842,4865-4868,4967,4971,4973-4975,4977,4980-4981,4989


Property changes on: branches/2.1/varnish-cache/lib/libvarnish/vev.c
___________________________________________________________________
Modified: svn:mergeinfo
   - /trunk/varnish-cache/lib/libvarnish/vev.c:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4829,4842,4865-4868,4971,4973-4975,4977,4980-4981,4989
   + /trunk/varnish-cache/lib/libvarnish/vev.c:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4829,4842,4865-4868,4967,4971,4973-4975,4977,4980-4981,4989

Modified: branches/2.1/varnish-cache/lib/libvcl/vcc_backend.c
===================================================================
--- branches/2.1/varnish-cache/lib/libvcl/vcc_backend.c	2010-07-13 08:52:54 UTC (rev 5039)
+++ branches/2.1/varnish-cache/lib/libvcl/vcc_backend.c	2010-07-13 09:03:13 UTC (rev 5040)
@@ -607,8 +607,6 @@
 
 		sprintf(vgcname, "%.*s_%d", PF(tl->t_dir), serial);
 
-		Ff(tl, 0, "\tVRT_fini_dir(cli, VGCDIR(_%.*s));\n",
-		    PF(tl->t_dir));
 		vcc_ParseHostDef(tl, serial, vgcname);
 		if (tl->err) {
 			vsb_printf(tl->sb,
@@ -672,6 +670,7 @@
 {
 	struct token *t_first;
 	struct dirlist const *dl;
+	int isfirst;
 
 	t_first = tl->t;
 	vcc_NextToken(tl);		/* ID: director | backend */
@@ -682,14 +681,12 @@
 	vcc_NextToken(tl);
 
 
+	isfirst = tl->ndirector;
 	if (vcc_IdIs(t_first, "backend")) {
 		tl->t_policy = t_first;
 		vcc_ParseSimpleDirector(tl);
 	} else {
-		Fh(tl, 1, "\n#define VGC_backend__%.*s %d\n",
-		    PF(tl->t_dir), tl->ndirector);
 		vcc_AddDef(tl, tl->t_dir, R_BACKEND);
-		tl->ndirector++;
 		ExpectErr(tl, ID);		/* ID: policy */
 		tl->t_policy = tl->t;
 		vcc_NextToken(tl);
@@ -708,9 +705,14 @@
 		dl->func(tl);
 		if (!tl->err)
 			SkipToken(tl, '}');
+		Fh(tl, 1, "\n#define VGC_backend__%.*s %d\n",
+		    PF(tl->t_dir), tl->ndirector);
+		tl->ndirector++;
 		Fi(tl, 0,
 		    "\tVRT_init_dir(cli, VCL_conf.director, \"%.*s\",\n",
 		    PF(tl->t_policy));
+		Ff(tl, 0, "\tVRT_fini_dir(cli, VGCDIR(_%.*s));\n",
+		    PF(tl->t_dir));
 		Fi(tl, 0, "\t    VGC_backend__%.*s, &vgc_dir_priv_%.*s);\n",
 		    PF(tl->t_dir), PF(tl->t_dir));
 
@@ -722,6 +724,18 @@
 		vcc_ErrWhere(tl, t_first);
 		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);
+	}
+
 	tl->t_policy = NULL;
 	tl->t_dir = NULL;
 }

Modified: branches/2.1/varnish-cache/lib/libvcl/vcc_compile.c
===================================================================
--- branches/2.1/varnish-cache/lib/libvcl/vcc_compile.c	2010-07-13 08:52:54 UTC (rev 5039)
+++ branches/2.1/varnish-cache/lib/libvcl/vcc_compile.c	2010-07-13 09:03:13 UTC (rev 5040)
@@ -469,6 +469,7 @@
 	VTAILQ_INIT(&tl->sources);
 
 	tl->nsources = 0;
+	tl->ndirector = 1;
 
 	/* General C code */
 	tl->fc = vsb_newauto();
@@ -580,7 +581,7 @@
 		return (vcc_DestroyTokenList(tl, NULL));
 
 	/* Check if we have any backends at all */
-	if (tl->ndirector == 0) {
+	if (tl->ndirector == 1) {
 		vsb_printf(tl->sb,
 		    "No backends or directors found in VCL program, "
 		    "at least one is necessary.\n");


Property changes on: branches/2.1/varnish-cache/lib/libvcl/vcc_dir_random.c
___________________________________________________________________
Modified: svn:mergeinfo
   - /trunk/varnish-cache/lib/libvcl/vcc_dir_random.c:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4829,4842,4865-4868,4971,4973-4975,4977,4980-4981,4989
   + /trunk/varnish-cache/lib/libvcl/vcc_dir_random.c:4637,4643-4645,4647-4650,4654-4670,4686,4689-4690,4700,4712,4715-4719,4731,4750,4757-4758,4762,4783,4818,4829,4842,4865-4868,4967,4971,4973-4975,4977,4980-4981,4989

Modified: branches/2.1/varnish-cache/lib/libvcl/vcc_xref.c
===================================================================
--- branches/2.1/varnish-cache/lib/libvcl/vcc_xref.c	2010-07-13 08:52:54 UTC (rev 5039)
+++ branches/2.1/varnish-cache/lib/libvcl/vcc_xref.c	2010-07-13 09:03:13 UTC (rev 5040)
@@ -142,10 +142,6 @@
 	}
 	r->defcnt++;
 	r->name = t;
-
-	/* The first backend is the default and thus has an implicit ref */
-	if (type == R_BACKEND && tl->ndirector == 0)
-		r->refcnt++;
 }
 
 /*--------------------------------------------------------------------*/




More information about the varnish-commit mailing list