[master] 33ad6de7f Move bereq.http to req->ws for vcl_pipe
Nils Goroll
nils.goroll at uplex.de
Mon Jan 11 14:26:03 UTC 2021
commit 33ad6de7fe590d90425c94a9c79ce912291a3f43
Author: Reza Naghibi <reza at naghibi.com>
Date: Thu Oct 15 09:40:09 2020 -0400
Move bereq.http to req->ws for vcl_pipe
Also make sure we didn't overflow before entering vcl_pipe. This would
mean we have lost important connection headers.
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 7c4e7c036..452dc344a 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -745,7 +745,7 @@ cnt_pipe(struct worker *wrk, struct req *req)
bo->sp = req->sp;
SES_Ref(bo->sp);
- HTTP_Setup(bo->bereq, bo->ws, bo->vsl, SLT_BereqMethod);
+ HTTP_Setup(bo->bereq, req->ws, bo->vsl, SLT_BereqMethod);
http_FilterReq(bo->bereq, req->http, 0); // XXX: 0 ?
http_PrintfHeader(bo->bereq, "X-Varnish: %u", VXID(req->vsl->wid));
http_ForceHeader(bo->bereq, H_Connection, "close");
@@ -756,7 +756,10 @@ cnt_pipe(struct worker *wrk, struct req *req)
}
bo->wrk = wrk;
- VCL_pipe_method(req->vcl, wrk, req, bo, NULL);
+ if (WS_Overflowed(req->ws))
+ wrk->handling = VCL_RET_FAIL;
+ else
+ VCL_pipe_method(req->vcl, wrk, req, bo, NULL);
switch (wrk->handling) {
case VCL_RET_SYNTH:
diff --git a/bin/varnishtest/tests/r03329.vtc b/bin/varnishtest/tests/r03329.vtc
index f3453bb61..8889f4061 100644
--- a/bin/varnishtest/tests/r03329.vtc
+++ b/bin/varnishtest/tests/r03329.vtc
@@ -3,11 +3,20 @@ varnishtest "Lost reason from pipe to synth"
server s1 {} -start
varnish v1 -vcl+backend {
+ import vtc;
sub vcl_recv {
+ if (req.http.workspace) {
+ vtc.workspace_alloc(client, -10);
+ }
return (pipe);
}
sub vcl_pipe {
- return (synth(505, req.http.foo + "/bar"));
+ if (req.http.foo) {
+ return (synth(505, req.http.foo + "/bar"));
+ } else {
+ set bereq.http.baz = "baz";
+ return (synth(505, bereq.http.baz));
+ }
}
} -start
@@ -15,4 +24,12 @@ client c1 {
txreq -hdr "foo: foo"
rxresp
expect resp.reason == "foo/bar"
+
+ txreq
+ rxresp
+ expect resp.reason == "baz"
+
+ txreq -hdr "workspace: true"
+ rxresp
+ expect resp.status == 503
} -run
More information about the varnish-commit
mailing list