Commit 49ad1b21 authored by Pål Hermunn Johansen's avatar Pål Hermunn Johansen

Fix a panic in VRB_Cache

This adds error handling for STV_NewObject(.., TRANSIENT) in VRB_Cache,
which would fail when transient is full.

This is a back port of 6045eaaa.

Fixes: #2831

Conflicts:
	bin/varnishd/cache/cache_req_body.c
	bin/varnishtest/tests/r02831.vtc
parent 2c1b624e
......@@ -239,7 +239,12 @@ VRB_Cache(struct req *req, ssize_t maxsize)
req->body_oc = HSH_Private(req->wrk);
AN(req->body_oc);
XXXAN(STV_NewObject(req->body_oc, req->wrk, TRANSIENT_STORAGE, 8));
if (STV_NewObject(req->body_oc, req->wrk, TRANSIENT_STORAGE, 8) == 0) {
(void)VFP_Error(vfc, "Object allocation failed -"
" ran out of space in Transient");
req->req_body_status = REQ_BODY_FAIL;
return (-1);
}
vfc->http = req->http;
vfc->oc = req->body_oc;
......
varnishtest "#2831: Out of storage in cache_req_body"
server s1 {
rxreq
expect req.url == "/obj1"
txresp -bodylen 1048400
} -start
varnish v1 \
-arg "-p nuke_limit=0" \
-arg "-sTransient=malloc,1m" \
-vcl+backend {
import ${vmod_std};
sub vcl_recv {
if (req.method == "POST") {
std.cache_req_body(1KB);
}
}
sub vcl_backend_response {
set beresp.do_stream = false;
set beresp.storage_hint = "Transient";
# Unset Date header to not change the object sizes
unset beresp.http.Date;
}
} -start
varnish v1 -cliok "param.set debug +syncvsl"
delay .1
client c1 {
# Fill transient
txreq -url "/obj1"
rxresp
expect resp.status == 200
} -run
delay .1
varnish v1 -expect SMA.Transient.g_bytes > 1048400
varnish v1 -expect SMA.Transient.g_space < 100
client c1 {
# No space for caching this req.body
txreq -req "POST" -body "foobar"
delay 1
} -run
varnish v1 -expect SMA.Transient.c_fail == 1
client c1 {
# Check that Varnish is still alive
txreq -url "/obj1"
rxresp
expect resp.status == 200
} -run
=================================
Varnish Cache 4.1.11 (unreleased)
=================================
Changes since 4.1.10:
* New counter added: cache_hit_grace (2831_)
.. _2831: https://github.com/varnishcache/varnish-cache/issues/2831
=================================
Varnish Cache 4.1.10 (2018-04-25)
=================================
......
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