Commit c9db023f authored by Poul-Henning Kamp's avatar Poul-Henning Kamp Committed by Tollef Fog Heen

Return false if req.backend.health is accessed in vcl_deliver{} where

this information is no longer available.

Fixes #1228
parent 3b49dc9d
......@@ -536,6 +536,12 @@ unsigned
VRT_r_req_backend_healthy(const struct sess *sp)
{
CHECK_OBJ_NOTNULL(sp, SESS_MAGIC);
/*
* XXX: Not optimal, but we do not have a backend in vcl_deliver
* XXX: and we have to return something.
*/
if (sp->director == NULL)
return (0);
CHECK_OBJ_NOTNULL(sp->director, DIRECTOR_MAGIC);
return (VDI_Healthy(sp->director, sp));
}
......
varnishtest "req.backend.healthy in vcl_deliver"
server s1 {
rxreq
txresp
} -start
varnish v1 -vcl+backend {
sub vcl_deliver {
set resp.http.x-foo = req.backend.healthy;
}
} -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