Commit d27d1478 authored by Tollef Fog Heen's avatar Tollef Fog Heen

Error out when reaching max_restarts

Partially addresses #280


git-svn-id: http://www.varnish-cache.org/svn/trunk/varnish-cache@3265 d4fa192b-c00b-0410-8231-f00ffab90ce4
parent d4165a96
......@@ -855,6 +855,12 @@ cnt_recv(struct sess *sp)
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;
......
# $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
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment