[6.0] 73262b47c Clear the status and response on a retry
Reza Naghibi
reza at naghibi.com
Tue Apr 20 18:11:07 UTC 2021
commit 73262b47c8e07597fcf9965fdc4bc5cf28e68ec1
Author: Steven <wojcikjsteven at gmail.com>
Date: Thu Feb 18 12:06:53 2021 -0500
Clear the status and response on a retry
The bo fields err_code and err_reason need to be reset on a retry otherwise the values are kept.
Fixes #3525
diff --git a/bin/varnishd/cache/cache_fetch.c b/bin/varnishd/cache/cache_fetch.c
index 6381bcfaf..026b61452 100644
--- a/bin/varnishd/cache/cache_fetch.c
+++ b/bin/varnishd/cache/cache_fetch.c
@@ -288,6 +288,8 @@ vbf_stp_retry(struct worker *wrk, struct busyobj *bo)
bo->do_esi = 0;
bo->do_stream = 1;
bo->was_304 = 0;
+ bo->err_code = 0;
+ bo->err_reason = NULL;
// XXX: BereqEnd + BereqAcct ?
VSL_ChgId(bo->vsl, "bereq", "retry", VXID_Get(wrk, VSL_BACKENDMARKER));
diff --git a/bin/varnishtest/tests/r03525.vtc b/bin/varnishtest/tests/r03525.vtc
new file mode 100644
index 000000000..75011e81e
--- /dev/null
+++ b/bin/varnishtest/tests/r03525.vtc
@@ -0,0 +1,24 @@
+varnishtest "Clear beresp status and reason on a retry"
+
+server s1 {
+ rxreq
+ txresp -status 500 -reason "my reason"
+} -start
+
+varnish v1 -arg "-p first_byte_timeout=0.2" -vcl+backend {
+ sub vcl_backend_response {
+ return (error(beresp.status, beresp.reason));
+ }
+ sub vcl_backend_error {
+ if (bereq.retries == 0) {
+ return (retry);
+ }
+ }
+} -start
+
+client c1 {
+ txreq
+ rxresp
+ expect resp.status == 503
+ expect resp.reason == "Backend fetch failed"
+} -run
More information about the varnish-commit
mailing list