std.cache_req_body() w/ return(pipe) is broken #1881

Closed
daghf opened this Issue Mar 15, 2016 · 2 comments

Projects

None yet

4 participants

@daghf
Contributor
daghf commented Mar 15, 2016

Expected Behavior

Varnish should pass the cached request body also in the event that the request was piped.

Current Behavior

The request body is drained when we do std.cache_req_body(), and since the busyobj for a piped request does not have a bo->req pointer set, it will not be able to recover the cached body.

Steps to Reproduce

The following test case fails after a timeout since the backend expects a request body that is never transmitted.

varnishtest "cache_req_body + pipe does not play well"

server s1 {
    rxreq
    expect req.bodylen == 6
    expect req.http.foo == "true"
    txresp
} -start

varnish v1 -vcl+backend {
    import std;

    sub vcl_recv {
        set req.http.foo = std.cache_req_body(10KB);
        return (pipe);
    }
} -start

varnish v1 -cliok "param.set debug +syncvsl"

client c1 {
    txreq -body "foobar"
    rxresp
    expect resp.status == 200
} -run

Your Environment

  • Version used: master
@fgsch
Member
fgsch commented Jun 14, 2016 edited

This fixes it. Haven't looked at the implications of this change though.

diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index a2d830c..6e2478f 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -572,6 +572,10 @@ cnt_pipe(struct worker *wrk, struct req *req)
                nxt = REQ_FSM_MORE;
                break;
        case VCL_RET_PIPE:
+               AZ(bo->req);
+               AZ(bo->wrk);
+               bo->req = req;
+               bo->wrk = wrk;
                SES_Close(req->sp, VDI_Http1Pipe(req, bo));
                nxt = REQ_FSM_DONE;
                break;
@fgsch fgsch added a commit that closed this issue Jul 5, 2016
@fgsch fgsch Make req reachable from the pipe code
We will need it if the body was consumed due to a call to
std.cache_req_body (VRB_Cache).

Analysis and test by daghf.

Fixes #1881.
0953ac1
@fgsch fgsch closed this in 0953ac1 Jul 5, 2016
@hermunn hermunn added a commit that referenced this issue Aug 12, 2016
@fgsch @hermunn fgsch + hermunn Make req reachable from the pipe code
We will need it if the body was consumed due to a call to
std.cache_req_body (VRB_Cache).

Analysis and test by daghf.

Fixes #1881.

Conflicts:
	bin/varnishd/cache/cache_req_fsm.c
acc91cc
@hermunn
Contributor
hermunn commented Aug 12, 2016

Backport review: The commit 0953ac1 is backported as acc91cc.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment