Commit 7db894f9 authored by Poul-Henning Kamp's avatar Poul-Henning Kamp

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

this information is no longer available.

Fixes #1228
parent 042a2d63
......@@ -555,6 +555,12 @@ unsigned
VRT_r_req_backend_healthy(const struct req *req)
{
CHECK_OBJ_NOTNULL(req, REQ_MAGIC);
/*
* XXX: Not optimal, but we do not have a backend in vcl_deliver
* XXX: and we have to return something.
*/
if (req->director == NULL)
return (0);
CHECK_OBJ_NOTNULL(req->director, DIRECTOR_MAGIC);
return (VDI_Healthy(req->director, req));
}
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