Commit e5efc2c8 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

Implement failure in vcl_hash{}

parent 61a15cbf
......@@ -752,7 +752,10 @@ cnt_recv(struct worker *wrk, struct req *req)
SHA256_Init(&sha256ctx);
VCL_hash_method(req->vcl, wrk, req, NULL, &sha256ctx);
assert(wrk->handling == VCL_RET_LOOKUP);
if (wrk->handling == VCL_RET_FAIL)
recv_handling = wrk->handling;
else
assert(wrk->handling == VCL_RET_LOOKUP);
SHA256_Final(req->digest, &sha256ctx);
switch(recv_handling) {
......
......@@ -15,6 +15,11 @@ varnish v1 -vcl+backend {
debug.fail();
}
}
sub vcl_hash {
if (req.http.foo == "hash") {
debug.fail();
}
}
sub vcl_synth {
if (resp.status == 748) {
debug.fail();
......@@ -85,3 +90,24 @@ client c1 {
varnish v1 -expect sc_vcl_failure == 3
logexpect l1 -wait
#######################################################################
# Fail in vcl_hash, no handling in vcl_synth
logexpect l1 -v v1 -g raw {
expect * 1009 VCL_call "HASH"
expect 0 1009 Debug "Forced failure"
expect 0 1009 VCL_return "fail"
} -start
client c1 {
txreq -hdr "foo: hash"
rxresp
expect resp.status == 503
expect resp.reason == "VCL failed"
} -run
varnish v1 -expect sc_vcl_failure == 4
logexpect l1 -wait
......@@ -102,7 +102,7 @@ returns = (
),
('hash',
"C",
('lookup',)
('fail', 'lookup',)
),
('purge',
"C",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment