From: petter Date: Fri, 18 Jul 2008 07:01:42 +0000 (+0000) Subject: Added the parameter err_ttl, which sets the TTL for synthesized error pages. Default... X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d734ac066e5b33768bbea053fa6091aad538a344;p=varnish Added the parameter err_ttl, which sets the TTL for synthesized error pages. Default value is 0. Fixes #126. git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@2949 d4fa192b-c00b-0410-8231-f00ffab90ce4 --- diff --git a/varnish-cache/bin/varnishd/cache.h b/varnish-cache/bin/varnishd/cache.h index 77d89d15..637f47d7 100644 --- a/varnish-cache/bin/varnishd/cache.h +++ b/varnish-cache/bin/varnishd/cache.h @@ -567,7 +567,7 @@ void RES_BuildHttp(struct sess *sp); void RES_WriteObj(struct sess *sp); /* cache_synthetic.c */ -void SYN_ErrorPage(struct sess *sp, int status, const char *reason); +void SYN_ErrorPage(struct sess *sp, int status, const char *reason, int ttl); /* cache_vary.c */ void VRY_Create(const struct sess *sp); diff --git a/varnish-cache/bin/varnishd/cache_center.c b/varnish-cache/bin/varnishd/cache_center.c index 61d76333..da05126c 100644 --- a/varnish-cache/bin/varnishd/cache_center.c +++ b/varnish-cache/bin/varnishd/cache_center.c @@ -309,7 +309,7 @@ cnt_error(struct sess *sp) { AZ(sp->obj); - SYN_ErrorPage(sp, sp->err_code, sp->err_reason); + SYN_ErrorPage(sp, sp->err_code, sp->err_reason, params->err_ttl); sp->err_code = 0; sp->err_reason = NULL; sp->step = STP_DONE; @@ -878,7 +878,7 @@ cnt_start(struct sess *sp) *sp->http0 = *sp->http; if (done != 0) { - SYN_ErrorPage(sp, done, NULL); /* XXX: STP_ERROR ? */ + SYN_ErrorPage(sp, done, NULL, params->err_ttl); /* XXX: STP_ERROR ? */ sp->step = STP_DONE; return (0); } diff --git a/varnish-cache/bin/varnishd/cache_synthetic.c b/varnish-cache/bin/varnishd/cache_synthetic.c index 23fb563a..8c0b4171 100644 --- a/varnish-cache/bin/varnishd/cache_synthetic.c +++ b/varnish-cache/bin/varnishd/cache_synthetic.c @@ -47,7 +47,7 @@ */ void -SYN_ErrorPage(struct sess *sp, int status, const char *reason) +SYN_ErrorPage(struct sess *sp, int status, const char *reason, int ttl) { struct http *h; struct worker *w; @@ -57,7 +57,6 @@ SYN_ErrorPage(struct sess *sp, int status, const char *reason) unsigned u; struct vsb vsb; int fd; - int ttl = 0; /* XXX: ?? */ WSL_Flush(sp->wrk, 0); assert(status >= 100 && status <= 999); diff --git a/varnish-cache/bin/varnishd/heritage.h b/varnish-cache/bin/varnishd/heritage.h index 85d5456d..767ac8c7 100644 --- a/varnish-cache/bin/varnishd/heritage.h +++ b/varnish-cache/bin/varnishd/heritage.h @@ -77,6 +77,9 @@ struct params { /* TTL used for lack of anything better */ unsigned default_ttl; + + /* TTL used for synthesized error pages */ + unsigned err_ttl; /* Worker threads and pool */ unsigned wthread_min; diff --git a/varnish-cache/bin/varnishd/mgt_param.c b/varnish-cache/bin/varnishd/mgt_param.c index 936733f0..416b0d94 100644 --- a/varnish-cache/bin/varnishd/mgt_param.c +++ b/varnish-cache/bin/varnishd/mgt_param.c @@ -784,6 +784,10 @@ static const struct parspec parspec[] = { "Use 0x notation and do the bitor in your head :-)\n", 0, "0", "bitmap" }, + { "err_ttl", tweak_uint, &master.err_ttl, 0, UINT_MAX, + "The TTL assigned to the synthesized error pages\n", + 0, + "0", "seconds" }, { NULL, NULL, NULL } }; diff --git a/varnish-cache/bin/varnishd/varnishd.1 b/varnish-cache/bin/varnishd/varnishd.1 index 400ab2d4..c30ccaff 100644 --- a/varnish-cache/bin/varnishd/varnishd.1 +++ b/varnish-cache/bin/varnishd/varnishd.1 @@ -389,6 +389,10 @@ nor the configuration assign one. Note that changes to this parameter are not applied retroactively. .Pp The default is 120 seconds. +.It Va err_ttl +The default time-to-live assigned to the synthesized error pages. +.Pp +The default is 0 seconds. .It Va fetch_chunksize The default chunk size used when retrieving documents for which the backend server does not specify a content length.