r3419 - in branches/nuke/varnish-cache: . bin/varnishd bin/varnishncsa bin/varnishreplay bin/varnishtest doc include lib/libvcl redhat

sky at projects.linpro.no sky at projects.linpro.no
Mon Nov 24 10:25:56 CET 2008


Author: sky
Date: 2008-11-24 10:25:56 +0100 (Mon, 24 Nov 2008)
New Revision: 3419

Modified:
   branches/nuke/varnish-cache/bin/varnishd/cache_ban.c
   branches/nuke/varnish-cache/bin/varnishd/cache_dir_random.c
   branches/nuke/varnish-cache/bin/varnishd/cache_hash.c
   branches/nuke/varnish-cache/bin/varnishd/cache_vrt.c
   branches/nuke/varnish-cache/bin/varnishd/cache_vrt_esi.c
   branches/nuke/varnish-cache/bin/varnishd/heritage.h
   branches/nuke/varnish-cache/bin/varnishd/mgt_param.c
   branches/nuke/varnish-cache/bin/varnishncsa/varnishncsa.c
   branches/nuke/varnish-cache/bin/varnishreplay/varnishreplay.c
   branches/nuke/varnish-cache/bin/varnishtest/Makefile.am
   branches/nuke/varnish-cache/configure.ac
   branches/nuke/varnish-cache/doc/changes-2.0-2.0.1.xml
   branches/nuke/varnish-cache/include/stat_field.h
   branches/nuke/varnish-cache/lib/libvcl/vcc_compile.c
   branches/nuke/varnish-cache/redhat/varnish.spec
Log:
rebase on release 2.0.2 

Modified: branches/nuke/varnish-cache/bin/varnishd/cache_ban.c
===================================================================
--- branches/nuke/varnish-cache/bin/varnishd/cache_ban.c	2008-11-22 01:35:16 UTC (rev 3418)
+++ branches/nuke/varnish-cache/bin/varnishd/cache_ban.c	2008-11-24 09:25:56 UTC (rev 3419)
@@ -49,6 +49,8 @@
 #define BAN_MAGIC		0x700b08ea
 	VTAILQ_ENTRY(ban)	list;
 	unsigned		refcount;
+	int			flags;
+#define BAN_F_GONE		(1 << 0)
 	regex_t			regexp;
 	char			*ban;
 	int			hash;
@@ -68,8 +70,9 @@
 int
 BAN_Add(struct cli *cli, const char *regexp, int hash)
 {
-	struct ban *b;
+	struct ban *b, *bi, *be;
 	char buf[512];
+	unsigned pcount;
 	int i;
 
 	ALLOC_OBJ(b, BAN_MAGIC);
@@ -97,8 +100,37 @@
 	ban_start = b;
 	VSL_stats->n_purge++;
 	VSL_stats->n_purge_add++;
+
+	if (params->purge_dups) {
+		be = VTAILQ_LAST(&ban_head, banhead);
+		be->refcount++;
+	} else
+		be = NULL;
 	UNLOCK(&ban_mtx);
 
+	if (be == NULL)
+		return (0);
+
+	/* Hunt down duplicates, and mark them as gone */
+	bi = b;
+	pcount = 0;
+	while(bi != be) {
+		bi = VTAILQ_NEXT(bi, list);
+		if (bi->flags & BAN_F_GONE)
+			continue;
+		if (b->hash != bi->hash)
+			continue;
+		if (strcmp(b->ban, bi->ban))
+			continue;
+		bi->flags |= BAN_F_GONE;
+		pcount++;
+	}
+	LOCK(&ban_mtx);
+	be->refcount--;
+	/* XXX: We should check if the tail can be removed */
+	VSL_stats->n_purge_dups += pcount;
+	UNLOCK(&ban_mtx);
+
 	return (0);
 }
 
@@ -168,7 +200,8 @@
 	tests = 0;
 	for (b = b0; b != o->ban; b = VTAILQ_NEXT(b, list)) {
 		tests++;
-		if (!regexec(&b->regexp, b->hash ? hash : url, 0, NULL, 0))
+		if (!(b->flags & BAN_F_GONE) &&
+		    !regexec(&b->regexp, b->hash ? hash : url, 0, NULL, 0))
 			break;
 	}
 
@@ -227,8 +260,8 @@
 	for (b0 = ban_start; b0 != NULL; b0 = VTAILQ_NEXT(b0, list)) {
 		if (b0->refcount == 0 && VTAILQ_NEXT(b0, list) == NULL)
 			break;
-		cli_out(cli, "%5u %s \"%s\"\n",
-		    b0->refcount,
+		cli_out(cli, "%5u %d %s \"%s\"\n",
+		    b0->refcount, b0->flags,
 		    b0->hash ? "hash" : "url ",
 		    b0->ban);
 	}

Modified: branches/nuke/varnish-cache/bin/varnishd/cache_dir_random.c
===================================================================
--- branches/nuke/varnish-cache/bin/varnishd/cache_dir_random.c	2008-11-22 01:35:16 UTC (rev 3418)
+++ branches/nuke/varnish-cache/bin/varnishd/cache_dir_random.c	2008-11-24 09:25:56 UTC (rev 3419)
@@ -66,9 +66,9 @@
 static struct vbe_conn *
 vdi_random_getfd(struct sess *sp)
 {
-	int i, j, k;
+	int i, k;
 	struct vdi_random *vs;
-	double r, s1, s2;
+	double r, s1;
 	struct vbe_conn *vbe;
 
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
@@ -78,45 +78,34 @@
 	k = 0;
 	for (k = 0; k < vs->retries; ) {
 
-		r = random() / 2147483648.0;	/* 2^31 */
-		assert(r >= 0.0 && r < 1.0);
-
+		/* Sum up the weights of healty backends */
 		s1 = 0.0;
-		j = 0;
-		for (i = 0; i < vs->nhosts; i++) {
-			if (!vs->hosts[i].backend->healthy)
-				continue;
-			s1 += vs->hosts[i].weight;
-			j++;
-		}	
+		for (i = 0; i < vs->nhosts; i++)
+			if (vs->hosts[i].backend->healthy)
+				s1 += vs->hosts[i].weight;
 
-		if (j == 0)		/* No healthy hosts */
+		if (s1 == 0.0)
 			return (NULL);
 
+		/* Pick a random threshold in that interval */
+		r = random() / 2147483648.0;	/* 2^31 */
+		assert(r >= 0.0 && r < 1.0);
 		r *= s1;
 
-		s2 = 0;
+		s1 = 0.0;
 		for (i = 0; i < vs->nhosts; i++)  {
 			if (!vs->hosts[i].backend->healthy)
 				continue;
-			s2 += vs->hosts[i].weight;
-			if (r < s2)
-				break;
+			s1 += vs->hosts[i].weight;
+			if (r >= s1)
+				continue;
+			vbe = VBE_GetVbe(sp, vs->hosts[i].backend);
+			if (vbe != NULL)
+				return (vbe);
+			break;
 		}
-
-		if (s2 != s1) {
-			/*
-			 * Health bit changed in an unusable way while we
-			 * worked the problem.  Usable changes are any that
-			 * result in the same sum we prepared for.
-			 */
-			continue;
-		}
-		vbe = VBE_GetVbe(sp, vs->hosts[i].backend);
-		if (vbe != NULL)
-			return (vbe);
 		k++;
-	} 
+	}
 	return (NULL);
 }
 

Modified: branches/nuke/varnish-cache/bin/varnishd/cache_hash.c
===================================================================
--- branches/nuke/varnish-cache/bin/varnishd/cache_hash.c	2008-11-22 01:35:16 UTC (rev 3418)
+++ branches/nuke/varnish-cache/bin/varnishd/cache_hash.c	2008-11-24 09:25:56 UTC (rev 3419)
@@ -281,7 +281,8 @@
 
 	if (busy_o != NULL) {
 		/* There are one or more busy objects, wait for them */
-		VTAILQ_INSERT_TAIL(&oh->waitinglist, sp, list);
+		if (sp->esis == 0)
+			VTAILQ_INSERT_TAIL(&oh->waitinglist, sp, list);
 		sp->objhead = oh;
 		UNLOCK(&oh->mtx);
 		return (NULL);

Modified: branches/nuke/varnish-cache/bin/varnishd/cache_vrt.c
===================================================================
--- branches/nuke/varnish-cache/bin/varnishd/cache_vrt.c	2008-11-22 01:35:16 UTC (rev 3418)
+++ branches/nuke/varnish-cache/bin/varnishd/cache_vrt.c	2008-11-24 09:25:56 UTC (rev 3419)
@@ -284,8 +284,8 @@
 VRT_r_resp_status(const struct sess *sp)
 {
 	CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
-	CHECK_OBJ_NOTNULL(sp->obj, OBJECT_MAGIC);
-	return (atoi(sp->obj->http->hd[HTTP_HDR_STATUS].b));
+	CHECK_OBJ_NOTNULL(sp->http, HTTP_MAGIC);
+	return (atoi(sp->http->hd[HTTP_HDR_STATUS].b));
 }
 
 /*--------------------------------------------------------------------*/

Modified: branches/nuke/varnish-cache/bin/varnishd/cache_vrt_esi.c
===================================================================
--- branches/nuke/varnish-cache/bin/varnishd/cache_vrt_esi.c	2008-11-22 01:35:16 UTC (rev 3418)
+++ branches/nuke/varnish-cache/bin/varnishd/cache_vrt_esi.c	2008-11-24 09:25:56 UTC (rev 3419)
@@ -796,7 +796,6 @@
 void
 ESI_Deliver(struct sess *sp)
 {
-
 	struct esi_bit *eb;
 	struct object *obj;
 
@@ -839,7 +838,16 @@
 		sp->step = STP_RECV;
 		http_ForceGet(sp->http);
 		http_Unset(sp->http, H_Content_Length);
-		CNT_Session(sp);
+		while (1) {
+			CNT_Session(sp);
+			if (sp->step == STP_DONE)
+				break;
+			AN(sp->wrk);
+			WSL_Flush(sp->wrk, 0);
+			DSL(0x20, SLT_Debug, sp->id, "loop waiting for ESI");
+			usleep(10000);
+		}
+		assert(sp->step == STP_DONE);
 		sp->esis--;
 		sp->obj = obj;
 

Modified: branches/nuke/varnish-cache/bin/varnishd/heritage.h
===================================================================
--- branches/nuke/varnish-cache/bin/varnishd/heritage.h	2008-11-22 01:35:16 UTC (rev 3418)
+++ branches/nuke/varnish-cache/bin/varnishd/heritage.h	2008-11-24 09:25:56 UTC (rev 3419)
@@ -183,6 +183,9 @@
 	/* Amount of time to sleep when running out of file
 	   descriptors.  In msecs */
 	unsigned		accept_fd_holdoff;
+
+	/* Get rid of duplicate purges */
+	unsigned		purge_dups;
 };
 
 extern volatile struct params *params;

Modified: branches/nuke/varnish-cache/bin/varnishd/mgt_param.c
===================================================================
--- branches/nuke/varnish-cache/bin/varnishd/mgt_param.c	2008-11-22 01:35:16 UTC (rev 3418)
+++ branches/nuke/varnish-cache/bin/varnishd/mgt_param.c	2008-11-24 09:25:56 UTC (rev 3419)
@@ -817,6 +817,10 @@
 		"The TTL assigned to the synthesized error pages\n",
 		0,
 		"0", "seconds" },
+	{ "purge_dups", tweak_bool, &master.purge_dups, 0, 0,
+		"Detect and eliminate duplicate purges.\n",
+		0,
+		"off", "bool" },
 	{ NULL, NULL, NULL }
 };
 

Modified: branches/nuke/varnish-cache/bin/varnishncsa/varnishncsa.c
===================================================================
--- branches/nuke/varnish-cache/bin/varnishncsa/varnishncsa.c	2008-11-22 01:35:16 UTC (rev 3418)
+++ branches/nuke/varnish-cache/bin/varnishncsa/varnishncsa.c	2008-11-24 09:25:56 UTC (rev 3419)
@@ -441,7 +441,7 @@
 		if (lp->df_Host) {
 			if (strncmp(lp->df_Host, "http://", 7) != 0)
 				fprintf(fo, "http://");
-			fprintf(fo, lp->df_Host);
+			fprintf(fo, "%s", lp->df_Host);
 		}
 		fprintf(fo, "%s ", lp->df_Uq);
 		fprintf(fo, "%s\" ", lp->df_H);

Modified: branches/nuke/varnish-cache/bin/varnishreplay/varnishreplay.c
===================================================================
--- branches/nuke/varnish-cache/bin/varnishreplay/varnishreplay.c	2008-11-22 01:35:16 UTC (rev 3418)
+++ branches/nuke/varnish-cache/bin/varnishreplay/varnishreplay.c	2008-11-24 09:25:56 UTC (rev 3419)
@@ -743,7 +743,8 @@
 	signal(SIGPIPE, SIG_IGN);
 
 	pthread_attr_init(&thread_attr);
-	pthread_attr_setstacksize(&thread_attr, 16384);
+	/* XXX: seting the stack size manually reduces the memory usasage and increases speed */
+	pthread_attr_setstacksize(&thread_attr, 32768);
 
 	while (VSL_Dispatch(vd, gen_traffic, NULL) == 0)
 		/* nothing */ ;

Modified: branches/nuke/varnish-cache/bin/varnishtest/Makefile.am
===================================================================
--- branches/nuke/varnish-cache/bin/varnishtest/Makefile.am	2008-11-22 01:35:16 UTC (rev 3418)
+++ branches/nuke/varnish-cache/bin/varnishtest/Makefile.am	2008-11-24 09:25:56 UTC (rev 3419)
@@ -9,6 +9,8 @@
 
 bin_PROGRAMS =	varnishtest
 
+dist_man_MANS = varnishtest.1
+
 varnishtest_SOURCES = \
 		vtc.c \
 		vtc.h \

Modified: branches/nuke/varnish-cache/configure.ac
===================================================================
--- branches/nuke/varnish-cache/configure.ac	2008-11-22 01:35:16 UTC (rev 3418)
+++ branches/nuke/varnish-cache/configure.ac	2008-11-24 09:25:56 UTC (rev 3419)
@@ -3,7 +3,7 @@
 AC_PREREQ(2.59)
 AC_COPYRIGHT([Copyright (c) 2006-2008 Linpro AS / Verdens Gang AS])
 AC_REVISION([$Id$])
-AC_INIT([Varnish], [2.0.1], [varnish-dev at projects.linpro.no])
+AC_INIT([Varnish], [2.0.2], [varnish-dev at projects.linpro.no])
 AC_CONFIG_SRCDIR(include/varnishapi.h)
 AM_CONFIG_HEADER(config.h)
 

Modified: branches/nuke/varnish-cache/doc/changes-2.0-2.0.1.xml
===================================================================
--- branches/nuke/varnish-cache/doc/changes-2.0-2.0.1.xml	2008-11-22 01:35:16 UTC (rev 3418)
+++ branches/nuke/varnish-cache/doc/changes-2.0-2.0.1.xml	2008-11-24 09:25:56 UTC (rev 3419)
@@ -17,6 +17,7 @@
       <para>There was an off-by-one error in the ACL compilation.
       Now fixed.</para>
     </change>
+  </subsystem>
 
   <subsystem>
     <name>Red Hat spec file</name>

Modified: branches/nuke/varnish-cache/include/stat_field.h
===================================================================
--- branches/nuke/varnish-cache/include/stat_field.h	2008-11-22 01:35:16 UTC (rev 3418)
+++ branches/nuke/varnish-cache/include/stat_field.h	2008-11-24 09:25:56 UTC (rev 3419)
@@ -124,6 +124,7 @@
 MAC_STAT(n_purge_retire,	uint64_t, 'a', "N old purges deleted")
 MAC_STAT(n_purge_obj_test,	uint64_t, 'a', "N objects tested")
 MAC_STAT(n_purge_re_test,	uint64_t, 'a', "N regexps tested against")
+MAC_STAT(n_purge_dups,		uint64_t, 'a', "N duplicate purges removed")
 
 MAC_STAT(n_nuke_hit,            uint64_t, 'a', "N object headers marked as nuked")
 MAC_STAT(n_nuke_miss,           uint64_t, 'a', "N object headers not in cache")

Modified: branches/nuke/varnish-cache/lib/libvcl/vcc_compile.c
===================================================================
--- branches/nuke/varnish-cache/lib/libvcl/vcc_compile.c	2008-11-22 01:35:16 UTC (rev 3418)
+++ branches/nuke/varnish-cache/lib/libvcl/vcc_compile.c	2008-11-24 09:25:56 UTC (rev 3419)
@@ -286,8 +286,12 @@
 				pos++;
 
 		}
-		Fc(tl, 0, "  [%3u] = { %d, %8u, %4u, %3u, 0, \"%.*s\" },\n",
-		    t->cnt, sp->idx, t->b - sp->b, lin, pos + 1, PF(t));
+		Fc(tl, 0, "  [%3u] = { %d, %8u, %4u, %3u, 0, ",
+		    t->cnt, sp->idx, t->b - sp->b, lin, pos + 1);
+		if (t->tok == CSRC)
+			Fc(tl, 0, " \"C{\"},\n");
+		else
+			Fc(tl, 0, " \"%.*s\" },\n", PF(t));
 	}
 	Fc(tl, 0, "};\n");
 }

Modified: branches/nuke/varnish-cache/redhat/varnish.spec
===================================================================
--- branches/nuke/varnish-cache/redhat/varnish.spec	2008-11-22 01:35:16 UTC (rev 3418)
+++ branches/nuke/varnish-cache/redhat/varnish.spec	2008-11-24 09:25:56 UTC (rev 3419)
@@ -1,6 +1,6 @@
 Summary: Varnish is a high-performance HTTP accelerator
 Name: varnish
-Version: 2.0
+Version: 2.0.2
 Release: 1%{?dist}
 License: BSD
 Group: System Environment/Daemons
@@ -11,7 +11,7 @@
 # configure script. Release tarballs would not need this
 #BuildRequires: automake autoconf libtool
 BuildRequires: ncurses-devel libxslt groff
-Requires: kernel >= 2.6.0 varnish-libs = %{version}-%{release}
+Requires: varnish-libs = %{version}-%{release}
 Requires: logrotate
 Requires: ncurses
 Requires(pre): shadow-utils
@@ -43,7 +43,7 @@
 Summary: Development files for %{name}-libs
 Group: System Environment/Libraries
 BuildRequires: ncurses-devel
-Requires: kernel >= 2.6.0 varnish-libs = %{version}-%{release}
+Requires: varnish-libs = %{version}-%{release}
 
 %description libs-devel
 Development files for %{name}-libs
@@ -53,7 +53,7 @@
 #Summary: Files for static linking of %{name} library functions
 #Group: System Environment/Libraries
 #BuildRequires: ncurses-devel
-#Requires: kernel >= 2.6.0 varnish-libs-devel = %{version}-%{release}
+#Requires: varnish-libs-devel = %{version}-%{release}
 #
 #%description libs-static
 #Files for static linking of varnish library functions
@@ -220,6 +220,21 @@
 %postun libs -p /sbin/ldconfig
 
 %changelog
+* Mon Nov 10 2008 Ingvar Hagelund <ingvar at linpro.no> - 2.0.2-1
+  New upstream release 2.0.2. A bugfix release
+
+* Sun Nov 02 2008 Ingvar Hagelund <ingvar at linpro.no> - 2.0.1-2
+- Removed the requirement for kernel => 2.6.0. All supported
+  platforms meets this, and it generates strange errors in EPEL
+
+* Fri Oct 17 2008 Ingvar Hagelund <ingvar at linpro.no> - 2.0.1-1
+- 2.0.1 released, a bugfix release. New upstream sources
+- Package now also available in EPEL
+
+* Thu Oct 16 2008 Ingvar Hagelund <ingvar at linpro.no> - 2.0-2
+- Readded the debugflag patch. It's so practical
+- Added a strange workaround for make check on ppc64
+
 * Wed Oct 15 2008 Ingvar Hagelund <ingvar at linpro.no> - 2.0-1
 - 2.0 released. New upstream sources
 - Disabled jemalloc on ppc and ppc64. Added a note in README.redhat.



More information about the varnish-commit mailing list