Commit 8633ce15 authored by Nils Goroll's avatar Nils Goroll

Fix an off-by-one in the max_restarts check

max_restarts is the number of allowed restarts

Related to #2405
parent a51affc8
......@@ -727,7 +727,7 @@ cnt_restart(struct worker *wrk, struct req *req)
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
req->director_hint = NULL;
if (++req->restarts >= cache_param->max_restarts) {
if (++req->restarts > cache_param->max_restarts) {
VSLb(req->vsl, SLT_VCL_Error, "Too many restarts");
req->err_code = 503;
req->req_step = R_STP_SYNTH;
......
......@@ -26,15 +26,17 @@ varnish v1 -vcl+backend {
}
sub vcl_synth {
if (req.restarts == 2) {
# when we end up here, we have _exceeded_ the number
# allowed restarts
if (req.restarts == 3) {
set resp.status = 200;
set resp.reason = "restart=2";
} elsif (req.restarts > 2) {
set resp.reason = "restart=3";
} elsif (req.restarts > 3) {
set resp.status = 501;
set resp.reason = "restart>2";
} elsif (req.restarts < 2) {
set resp.reason = "restart>3";
} elsif (req.restarts < 3) {
set resp.status = 500;
set resp.reason = "restart<2";
set resp.reason = "restart<3";
}
}
} -start
......
......@@ -2,6 +2,10 @@
Varnish Cache Trunk (ongoing)
=============================
* Fixed implementation of the ``max_restarts`` limit: It used to be one
less than the number of allowed restarts, it now is the number of
``return(restart)``s per request.
================================
Varnish Cache 5.2.0 (2017-09-15)
================================
......
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