Skip to content

Commit

Permalink
add failure handling to vcl_pipe{}
Browse files Browse the repository at this point in the history
  • Loading branch information
bsdphk committed Feb 6, 2017
1 parent 851be37 commit ba54dc9
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 1 deletion.
4 changes: 4 additions & 0 deletions bin/varnishd/cache/cache_req_fsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,10 @@ cnt_pipe(struct worker *wrk, struct req *req)
VCL_pipe_method(req->vcl, wrk, req, bo, NULL);

switch (wrk->handling) {
case VCL_RET_FAIL:
req->req_step = R_STP_VCLFAIL;
nxt = REQ_FSM_MORE;
break;
case VCL_RET_SYNTH:
req->req_step = R_STP_SYNTH;
nxt = REQ_FSM_MORE;
Expand Down
31 changes: 31 additions & 0 deletions bin/varnishtest/tests/v00051.vtc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ server s1 {
varnish v1 -vcl+backend {
import debug;
sub vcl_recv {
if (req.http.foo == "pipe") {
return(pipe);
}
if (req.http.foo == "bar") {
return(synth(748));
}
Expand All @@ -22,6 +25,12 @@ varnish v1 -vcl+backend {
set req.http.not = "Should not happen";
}
}
sub vcl_pipe {
if (req.http.foo == "pipe") {
debug.fail();
set req.http.not = "Should not happen";
}
}
sub vcl_synth {
if (resp.status == 748) {
debug.fail();
Expand Down Expand Up @@ -114,3 +123,25 @@ varnish v1 -expect sc_vcl_failure == 4

logexpect l1 -wait

#######################################################################
# Fail in vcl_pipe, no handling in vcl_synth

logexpect l1 -v v1 -g raw {
expect * 1012 VCL_call "PIPE"
expect 0 1012 Debug "Forced failure"
expect 0 1012 VCL_return "fail"
} -start

client c1 {
txreq -hdr "foo: pipe"
rxresp
expect resp.status == 503
expect resp.reason == "VCL failed"
} -run

delay 1

varnish v1 -expect sc_vcl_failure == 5

logexpect l1 -wait

2 changes: 1 addition & 1 deletion lib/libvcc/generate.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@
),
('pipe',
"C",
('synth', 'pipe',)
('fail', 'synth', 'pipe',)
),
('pass',
"C",
Expand Down

0 comments on commit ba54dc9

Please sign in to comment.