[4.0] 33d80ab Implement "return(retry)" in vcl_backend_error{}
Poul-Henning Kamp
phk at FreeBSD.org
Thu Mar 13 10:24:31 CET 2014
commit 33d80aba55165ea35af1a182b2b6a45303075be0
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Tue Mar 11 09:07:53 2014 +0000
Implement "return(retry)" in vcl_backend_error{}
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 9368385..c3cefac 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -666,7 +666,20 @@ vbf_stp_error(struct worker *wrk, struct busyobj *bo)
AZ(VSB_finish(bo->synth_body));
- xxxassert(wrk->handling == VCL_RET_DELIVER);
+ if (wrk->handling == VCL_RET_RETRY) {
+ VSB_delete(bo->synth_body);
+ bo->synth_body = NULL;
+ if (bo->retries++ < cache_param->max_retries) {
+ return (F_STP_RETRY);
+ }
+ bo->synth_body = NULL;
+ HSH_Fail(bo->fetch_objcore);
+ VBO_setstate(bo, BOS_FAILED);
+ HSH_Complete(bo->fetch_objcore);
+ return (F_STP_DONE);
+ }
+
+ assert(wrk->handling == VCL_RET_DELIVER);
if (vbf_beresp2obj(bo)) {
VBO_setstate(bo, BOS_FAILED);
diff --git a/bin/varnishtest/tests/c00061.vtc b/bin/varnishtest/tests/c00061.vtc
new file mode 100644
index 0000000..ecb01a4
--- /dev/null
+++ b/bin/varnishtest/tests/c00061.vtc
@@ -0,0 +1,24 @@
+varnishtest "retry in vcl_backend_error"
+
+varnish v1 -vcl {
+
+ backend b1 { .host = "${bad_ip}"; }
+
+ sub vcl_backend_error {
+ return (retry);
+ }
+
+ sub vcl_error {
+ set obj.status = 504;
+ }
+} -start
+
+varnish v1 -cliok "param.set debug +syncvsl"
+varnish v1 -cliok "param.set connect_timeout 1"
+varnish v1 -cliok "param.set max_retries 2"
+
+client c1 {
+ txreq
+ rxresp
+ expect resp.status == 504
+} -run
More information about the varnish-commit
mailing list