[6.0] 700788cb2 Move bereq.http to req->ws for vcl_pipe
Reza Naghibi
reza at naghibi.com
Mon Nov 2 19:02:08 UTC 2020
commit 700788cb28cd7cbd938f39875e6c2f05aabbb98e
Author: Reza Naghibi <reza at naghibi.com>
Date: Mon Nov 2 14:01:11 2020 -0500
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 04470ab59..30b6fdc0b 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -770,7 +770,7 @@ cnt_pipe(struct worker *wrk, struct req *req)
SES_Ref(bo->sp);
VCL_TaskEnter(bo->vcl, bo->privs);
- 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");
@@ -780,7 +780,10 @@ cnt_pipe(struct worker *wrk, struct req *req)
req->want100cont = 0;
}
- 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_FAIL:
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