Commit a43326dd authored by Martin Blix Grydeland's avatar Martin Blix Grydeland

Rearm at zero TTL on failed objects

Fixes: #1468
parent acd718f0
......@@ -707,6 +707,11 @@ vbf_stp_fail(struct worker *wrk, struct busyobj *bo)
assert(bo->state < BOS_FINISHED);
HSH_Fail(bo->fetch_objcore);
if (bo->fetch_objcore->exp_flags & OC_EF_EXP) {
/* Already unbusied - expire it */
AN(bo->fetch_obj);
EXP_Rearm(bo->fetch_obj, bo->fetch_obj->exp.t_origin, 0, 0, 0);
}
wrk->stats.fetch_failed++;
VBO_setstate(bo, BOS_FAILED);
return (F_STP_DONE);
......
varnishtest "#1468 - freeing failed obj"
server s1 {
rxreq
expect req.url == "/1"
txresp -nolen -hdr "Transfer-Encoding: chunked"
chunked {<HTML>}
sema r1 sync 2
close
accept
rxreq
expect req.url == "/2"
txresp -nolen -hdr "Transfer-Encoding: chunked"
chunked {<HTML>}
sema r1 sync 2
} -start
varnish v1 -vcl+backend {
sub vcl_recv {
if (req.url == "/2") {
return (pass);
}
}
sub vcl_backend_response {
set beresp.ttl = 5m;
}
} -start
# Test the regular cached content case
client c1 {
txreq -url "/1"
rxresphdrs
expect resp.status == 200
rxchunk
sema r1 sync 2
expect_close
} -run
# Test the pass from vcl_recv case
client c1 {
txreq -url "/2"
rxresphdrs
expect resp.status == 200
rxchunk
sema r1 sync 2
expect_close
} -run
# Delay to allow expiry thread to do it's job
delay 1
varnish v1 -expect n_object == 0
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