Mailing List Archive

r3265 - in trunk/varnish-cache/bin: varnishd varnishtest/tests
Author: tfheen
Date: 2008-10-07 13:08:43 +0200 (Tue, 07 Oct 2008)
New Revision: 3265

Added:
trunk/varnish-cache/bin/varnishtest/tests/b00019.vtc
Modified:
trunk/varnish-cache/bin/varnishd/cache_center.c
Log:
Error out when reaching max_restarts

Partially addresses #280


Modified: trunk/varnish-cache/bin/varnishd/cache_center.c
===================================================================
--- trunk/varnish-cache/bin/varnishd/cache_center.c 2008-10-07 11:00:42 UTC (rev 3264)
+++ trunk/varnish-cache/bin/varnishd/cache_center.c 2008-10-07 11:08:43 UTC (rev 3265)
@@ -855,6 +855,12 @@
AN(sp->director);

VCL_recv_method(sp);
+ if (sp->restarts >= params->max_restarts) {
+ if (sp->err_code == 0)
+ sp->err_code = 503;
+ sp->step = STP_ERROR;
+ return (0);
+ }

sp->wantbody = (strcmp(sp->http->hd[HTTP_HDR_REQ].b, "HEAD") != 0);
sp->sendbody = 0;

Added: trunk/varnish-cache/bin/varnishtest/tests/b00019.vtc
===================================================================
--- trunk/varnish-cache/bin/varnishtest/tests/b00019.vtc (rev 0)
+++ trunk/varnish-cache/bin/varnishtest/tests/b00019.vtc 2008-10-07 11:08:43 UTC (rev 3265)
@@ -0,0 +1,48 @@
+# $Id$
+
+test "Check that max_restarts works and that we don't fall over"
+
+server s1 -repeat 6 {
+ rxreq
+ txresp -body "012345\n"
+} -start
+
+varnish v1 -vcl+backend {
+ sub vcl_fetch {
+ restart;
+ }
+
+ sub vcl_error {
+ if (req.restarts == 2) {
+ set obj.status = 200;
+ } elsif (req.restarts > 2) {
+ set obj.status = 501;
+ } elsif (req.restarts < 2) {
+ set obj.status = 500;
+ }
+ }
+} -start
+
+varnish v1 -cliok "param.set max_restarts 2"
+
+client c1 {
+ txreq -url "/"
+ rxresp
+ expect resp.status == 200
+} -run
+
+varnish v1 -cliok "param.set max_restarts 3"
+
+client c1 {
+ txreq -url "/"
+ rxresp
+ expect resp.status == 501
+} -run
+
+varnish v1 -cliok "param.set max_restarts 1"
+
+client c1 {
+ txreq -url "/"
+ rxresp
+ expect resp.status == 500
+} -run