r2068 - trunk/varnish-cache/bin/varnishd

phk at projects.linpro.no phk at projects.linpro.no
Sun Sep 30 23:11:21 CEST 2007


Author: phk
Date: 2007-09-30 23:11:21 +0200 (Sun, 30 Sep 2007)
New Revision: 2068

Modified:
   trunk/varnish-cache/bin/varnishd/cache_center.c
   trunk/varnish-cache/bin/varnishd/heritage.h
   trunk/varnish-cache/bin/varnishd/mgt_param.c
Log:
Make the number of restarts a parameter.


Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c	2007-09-30 20:57:30 UTC (rev 2067)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c	2007-09-30 21:11:21 UTC (rev 2068)
@@ -69,6 +69,7 @@
 
 #include "shmlog.h"
 #include "vcl.h"
+#include "heritage.h"
 #include "cache.h"
 
 static unsigned xids;
@@ -707,6 +708,10 @@
 
 	AZ(sp->obj);
 
+	if (sp->restarts > params->max_restarts) {
+		sp->step = STP_ERROR;
+		return (0);
+	}
 	if (sp->restarts == 0) {
 		AZ(sp->vcl);
 		/* Update stats of various sorts */

Modified: trunk/varnish-cache/bin/varnishd/heritage.h
===================================================================
--- trunk/varnish-cache/bin/varnishd/heritage.h	2007-09-30 20:57:30 UTC (rev 2067)
+++ trunk/varnish-cache/bin/varnishd/heritage.h	2007-09-30 21:11:21 UTC (rev 2068)
@@ -125,6 +125,9 @@
 	/* LRU list ordering interval */
 	unsigned		lru_timeout;
 
+	/* Maximum restarts allowed */
+	unsigned		max_restarts;
+
 };
 
 extern volatile struct params *params;

Modified: trunk/varnish-cache/bin/varnishd/mgt_param.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/mgt_param.c	2007-09-30 20:57:30 UTC (rev 2067)
+++ trunk/varnish-cache/bin/varnishd/mgt_param.c	2007-09-30 21:11:21 UTC (rev 2068)
@@ -555,6 +555,14 @@
 	}
 }
 
+static void
+tweak_max_restarts(struct cli *cli, struct parspec *par, const char *arg)
+{
+
+	(void)par;
+	tweak_generic_uint(cli, &master.max_restarts, arg, 0, UINT_MAX);
+}
+
 /*--------------------------------------------------------------------*/
 
 /*
@@ -760,6 +768,14 @@
 		"exec cc -nostdinc -fpic -shared -Wl,-x -o %s -x c - < %s"
 #endif
 		, NULL },
+	{ "max_restarts", tweak_max_restarts,
+		"Upper limit on how many times a request can restart."
+#ifdef NOT_YET
+		"  ESI:include counts as a restart in this context."
+#endif
+		"\nBe aware that restarts are likely to cause a hit against "
+		"the backend, so don't increase thoughtlessly.\n",
+		"4", "restarts" },
 	{ NULL, NULL, NULL }
 };
 




More information about the varnish-commit mailing list