Commit fe85c10c authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Handle the case where too many retries are attempted, by returning

a 503 reply.

Fixes #1401
parent 4b573e1e
......@@ -244,6 +244,8 @@ vbf_stp_fetchhdr(struct worker *wrk, struct busyobj *bo)
VCL_backend_response_method(bo->vcl, wrk, NULL, bo, bo->beresp->ws);
if (wrk->handling == VCL_RET_RETRY) {
if (bo->vbc)
VDI_CloseFd(&bo->vbc);
bo->retries++;
if (bo->retries <= cache_param->max_retries) {
// XXX: BereqEnd + BereqAcct ?
......@@ -254,10 +256,12 @@ vbf_stp_fetchhdr(struct worker *wrk, struct busyobj *bo)
owid = bo->vsl->wid & VSL_IDENTMASK;
bo->vsl->wid = wid | VSL_BACKENDMARKER;
VSLb(bo->vsl, SLT_Begin, "bereq %u retry", owid);
VDI_CloseFd(&bo->vbc);
return (F_STP_STARTFETCH);
}
INCOMPL();
VSLb(bo->vsl, SLT_VCL_Error,
"Too many retries, delivering 503");
make_it_503(bo);
wrk->handling = VCL_RET_DELIVER;
}
assert(bo->state == BOS_REQ_DONE);
......
varnishtest "too many retries"
server s1 {
rxreq
expect req.url == /1
txresp -hdr "foo: bar" -bodylen 5
accept
rxreq
expect req.url == /1
txresp -hdr "foo: foof" -hdr "Connection: close" -bodylen 7
accept
rxreq
expect req.url == /2
txresp -hdr "foo: bar" -bodylen 10
accept
rxreq
expect req.url == /2
txresp -hdr "foo: bar" -bodylen 11
accept
rxreq
expect req.url == /2
txresp -hdr "foo: bar" -bodylen 12
accept
rxreq
expect req.url == /2
txresp -hdr "foo: bar" -bodylen 13
accept
rxreq
expect req.url == /2
txresp -hdr "foo: bar" -bodylen 4
} -start
varnish v1 -vcl+backend {
sub vcl_backend_response {
if (beresp.http.foo == "bar") {
return (retry);
}
}
} -start
client c1 {
txreq -url /1
rxresp
expect resp.http.foo == foof
expect resp.bodylen == 7
} -run
delay .1
client c1 {
txreq -url /2
rxresp
expect resp.status == 503
} -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