[master] ba54dc9 add failure handling to vcl_pipe{}
Poul-Henning Kamp
phk at FreeBSD.org
Mon Feb 6 12:56:05 CET 2017
commit ba54dc919076b1ddb85434d886ce82a6553d926b
Author: Poul-Henning Kamp <phk at FreeBSD.org>
Date: Mon Feb 6 11:55:04 2017 +0000
add failure handling to vcl_pipe{}
diff --git a/bin/varnishd/cache/cache_req_fsm.c b/bin/varnishd/cache/cache_req_fsm.c
index 30fecde..e50d132 100644
--- a/bin/varnishd/cache/cache_req_fsm.c
+++ b/bin/varnishd/cache/cache_req_fsm.c
@@ -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;
diff --git a/bin/varnishtest/tests/v00051.vtc b/bin/varnishtest/tests/v00051.vtc
index 334d919..3a04517 100644
--- a/bin/varnishtest/tests/v00051.vtc
+++ b/bin/varnishtest/tests/v00051.vtc
@@ -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));
}
@@ -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();
@@ -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
+
diff --git a/lib/libvcc/generate.py b/lib/libvcc/generate.py
index ef77858..14e50a1 100755
--- a/lib/libvcc/generate.py
+++ b/lib/libvcc/generate.py
@@ -94,7 +94,7 @@ returns = (
),
('pipe',
"C",
- ('synth', 'pipe',)
+ ('fail', 'synth', 'pipe',)
),
('pass',
"C",
More information about the varnish-commit
mailing list