[master] af56b5c Set req.backend_hint from the VCL we switch to.
Poul-Henning Kamp
phk at FreeBSD.org
Mon Jan 2 20:29:04 CET 2017
commit af56b5c6e1052121733d30f3235317e0c004b772
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Jan 2 19:27:56 2017 +0000
Set req.backend_hint from the VCL we switch to.
Spotted by: dridi
Fixes: #2175
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 16fee9f..f5ea3ae 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -691,8 +691,11 @@ cnt_recv(struct worker *wrk, struct req *req)
}
VCL_recv_method(req->vcl, wrk, req, NULL, NULL);
- if (wrk->handling == VCL_RET_VCL)
+ if (wrk->handling == VCL_RET_VCL) {
+ req->director_hint = VCL_DefaultDirector(req->vcl);
+ AN(req->director_hint);
VCL_recv_method(req->vcl, wrk, req, NULL, NULL);
+ }
/* Attempts to cache req.body may fail */
if (req->req_body_status == REQ_BODY_FAIL) {
diff --git a/bin/varnishtest/tests/r02175.vtc b/bin/varnishtest/tests/r02175.vtc
new file mode 100644
index 0000000..1a33fe4
--- /dev/null
+++ b/bin/varnishtest/tests/r02175.vtc
@@ -0,0 +1,41 @@
+varnishtest "leak backend"
+
+server s1 {
+ rxreq
+ txresp -hdr "Leak: no"
+} -start
+
+server s2 {
+ rxreq
+ txresp -hdr "Leak: yes"
+} -start
+
+varnish v1 -vcl {
+ backend s1 { .host="${s1_addr}"; .port="${s1_port}"; }
+
+ sub vcl_deliver {
+ set resp.http.Label = "yes";
+ }
+}
+
+varnish v1 -cli "vcl.label lbl vcl1"
+
+varnish v1 -vcl {
+ backend s2 { .host="${s2_addr}"; .port="${s2_port}"; }
+
+ sub vcl_recv {
+ set req.backend_hint = s2;
+ return (vcl(lbl));
+ }
+
+ sub vcl_deliver {
+ set resp.http.Label = "no";
+ }
+} -start
+
+client c1 {
+ txreq
+ rxresp
+ expect resp.http.Label == yes
+ expect resp.http.Leak == no
+} -run
More information about the varnish-commit
mailing list