Commit a39f3ee6 authored by Tollef Fog Heen's avatar Tollef Fog Heen

Reset bereq http struct on restart from vcl_miss and vcl_pass

Thanks a lot to David for minimised test case showing the bug.

Fixes: #965
parent f19fab60
......@@ -1155,6 +1155,7 @@ cnt_miss(struct sess *sp)
case VCL_RET_ERROR:
AZ(HSH_Deref(sp->wrk, sp->objcore, NULL));
sp->objcore = NULL;
http_Setup(sp->wrk->bereq, NULL);
sp->step = STP_ERROR;
return (0);
case VCL_RET_PASS:
......@@ -1223,6 +1224,7 @@ cnt_pass(struct sess *sp)
sp->wrk->between_bytes_timeout = 0;
VCL_pass_method(sp);
if (sp->handling == VCL_RET_ERROR) {
http_Setup(sp->wrk->bereq, NULL);
sp->step = STP_ERROR;
return (0);
}
......
varnishtest "restart in vcl_miss #965"
server s1 {
rxreq
txresp
} -start
varnish v1 -vcl+backend {
sub vcl_recv {
if (req.http.X-Banned == "check") { remove req.http.X-Banned; }
elseif (req.restarts == 0) {
set req.http.X-Banned = "check";
if (req.http.x-pass) {
return (pass);
} else {
return (lookup);
}
}
}
sub vcl_hash {
## Check if they have a ban in the cache, or if they are going to be banned in cache.
if (req.http.X-Banned) {
hash_data(client.ip);
return (hash);
}
}
sub vcl_error {
if (obj.status == 988) { return (restart); }
}
sub vcl_miss {
if (req.http.X-Banned == "check") { error 988 "restarting"; }
}
sub vcl_pass {
if (req.http.X-Banned == "check") { error 988 "restarting"; }
}
} -start
client c1 {
txreq
rxresp
expect resp.status == 200
txreq
rxresp
expect resp.status == 200
txreq -hdr "X-Pass: 1"
rxresp
expect resp.status == 200
} -run
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