[master] 40625f5 fix proxy backend in pipe mode

Nils Goroll nils.goroll at uplex.de
Fri Apr 6 15:24:11 UTC 2018


commit 40625f511564b1489b27aa2c8c76208b840d9878
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Thu Mar 15 16:58:42 2018 +0100

    fix proxy backend in pipe mode
    
    Fixes #2613

diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 4c8fad0..e327c0d 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -693,6 +693,8 @@ cnt_pipe(struct worker *wrk, struct req *req)
 	VSLb(bo->vsl, SLT_Begin, "bereq %u pipe", VXID(req->vsl->wid));
 	VSLb(req->vsl, SLT_Link, "bereq %u pipe", VXID(bo->vsl->wid));
 	THR_SetBusyobj(bo);
+	bo->sp = req->sp;
+	SES_Ref(bo->sp);
 
 	HTTP_Setup(bo->bereq, bo->ws, bo->vsl, SLT_BereqMethod);
 	http_FilterReq(bo->bereq, req->http, 0);	// XXX: 0 ?
@@ -726,6 +728,7 @@ cnt_pipe(struct worker *wrk, struct req *req)
 		WRONG("Illegal return from vcl_pipe{}");
 	}
 	http_Teardown(bo->bereq);
+	SES_Rel(bo->sp);
 	VBO_ReleaseBusyObj(wrk, &bo);
 	THR_SetBusyobj(NULL);
 	return (nxt);
diff --git a/bin/varnishtest/tests/o00002.vtc b/bin/varnishtest/tests/o00002.vtc
index 13fba7d..9217afa 100644
--- a/bin/varnishtest/tests/o00002.vtc
+++ b/bin/varnishtest/tests/o00002.vtc
@@ -34,6 +34,13 @@ server s1 {
 	expect req.http.xyzzy1 == 4444
 	expect req.http.x-forwarded-for == "1:f::2, 1:f::2"
 	txresp -body "proxy4"
+
+	rxreq
+	expect req.url == "/pipe"
+	expect req.http.xyzzy1 == req.http.xyzzy2
+	expect req.http.xyzzy1 == 5555
+	expect req.http.x-forwarded-for == "1:f::2, 1:f::2"
+	txresp -hdr "Connection: close" -body "pipe"
 } -start
 
 varnish v1 -proto PROXY -vcl+backend {
@@ -64,6 +71,9 @@ varnish v2 -proto PROXY -vcl {
 		} else {
 			set req.backend_hint = bp2;
 		}
+		if (req.url ~ "^/pipe") {
+			return (pipe);
+		}
 	}
 	sub vcl_deliver {
 		set resp.http.connection = "close";
@@ -97,3 +107,11 @@ client c1 -connect ${v2_sock} -proxy1 "[1:f::2]:4444 [5:a::8]:5678" {
 	expect resp.body == "proxy4"
 } -run
 delay .2
+
+client c1 -connect ${v2_sock} -proxy1 "[1:f::2]:5555 [5:a::8]:5678" {
+	txreq -url /pipe
+	rxresp
+	expect resp.body == "pipe"
+	expect resp.http.Connection == "close"
+	expect_close
+} -run


More information about the varnish-commit mailing list