fix bereq rollback with retry

When retrying after a rollback, we might have unread bytes of the
backend response body. As we need to finalize the director for rollback,
all we can do in this case is to close the connection.

Spotted by reza, who also provided the test case, thank you.

Closes #3353
parent 060175fe
......@@ -106,6 +106,11 @@ void Bereq_Rollback(struct busyobj *bo)
{
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
if (bo->htc != NULL &&
bo->htc->body_status != BS_NONE &&
bo->htc->body_status != BS_TAKEN)
bo->htc->doclose = SC_RESP_CLOSE;
vbf_cleanup(bo);
VCL_TaskLeave(bo->privs);
VCL_TaskEnter(bo->privs);
......
varnishtest "Test rollback and retry"
server s1 {
rxreq
txresp -nolen -hdr "Content-Length: 3"
expect_close
accept
rxreq
txresp -body xxx
} -start
varnish v1 -vcl+backend {
import std;
sub vcl_backend_response {
if (bereq.retries == 0) {
std.rollback(bereq);
}
}
sub vcl_backend_error {
if (bereq.retries == 0) {
return (retry);
}
}
} -start
client c1 {
txreq
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