From: phk Date: Sun, 30 Sep 2007 21:11:21 +0000 (+0000) Subject: Make the number of restarts a parameter. X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=784a5f3411de622c0a4d95cd84bb5a4ccbaed432;p=varnish Make the number of restarts a parameter. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2068 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache_center.c b/varnish-cache/bin/varnishd/cache_center.c index ac773a07..fd5f4e90 100644 --- a/varnish-cache/bin/varnishd/cache_center.c +++ b/varnish-cache/bin/varnishd/cache_center.c @@ -69,6 +69,7 @@ DOT start -> recv [style=bold,color=green,weight=4] #include "shmlog.h" #include "vcl.h" +#include "heritage.h" #include "cache.h" static unsigned xids; @@ -707,6 +708,10 @@ cnt_recv(struct sess *sp) 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 */ diff --git a/varnish-cache/bin/varnishd/heritage.h b/varnish-cache/bin/varnishd/heritage.h index 866d4017..7c0c3436 100644 --- a/varnish-cache/bin/varnishd/heritage.h +++ b/varnish-cache/bin/varnishd/heritage.h @@ -125,6 +125,9 @@ struct params { /* LRU list ordering interval */ unsigned lru_timeout; + /* Maximum restarts allowed */ + unsigned max_restarts; + }; extern volatile struct params *params; diff --git a/varnish-cache/bin/varnishd/mgt_param.c b/varnish-cache/bin/varnishd/mgt_param.c index fa8d9ff7..9247e38d 100644 --- a/varnish-cache/bin/varnishd/mgt_param.c +++ b/varnish-cache/bin/varnishd/mgt_param.c @@ -555,6 +555,14 @@ tweak_cc_command(struct cli *cli, struct parspec *par, const char *arg) } } +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 @@ static struct parspec parspec[] = { "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 } };