Skip to content

Commit

Permalink
Diffentiate "no backend" from "none resolved" in VDI_Resolve()
Browse files Browse the repository at this point in the history
recover a minor improvement from varnishcache#2680:

This commit is to emit slightly different error messages to
differentiate between the cases "no backend set in vcl" and
"none returned from the director".

Includes minor polishing

Ref varnishcache#2860 varnishcache#3311
  • Loading branch information
nigoroll committed May 24, 2020
1 parent b3ec626 commit 136dde5
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions bin/varnishd/cache/cache_director.c
Expand Up @@ -103,24 +103,26 @@ VRT_VDI_Resolve(VRT_CTX, VCL_BACKEND d)
static VCL_BACKEND
VDI_Resolve(VRT_CTX)
{
const struct director *d;
VCL_BACKEND d;
struct busyobj *bo;

CHECK_OBJ_NOTNULL(ctx, VRT_CTX_MAGIC);
bo = ctx->bo;
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_MAGIC);
CHECK_OBJ_ORNULL(bo->director_req, DIRECTOR_MAGIC);
d = VRT_VDI_Resolve(ctx, bo->director_req);
CHECK_OBJ_ORNULL(d, DIRECTOR_MAGIC);
if (d == NULL) {
VSLb(bo->vsl, SLT_FetchError, "No backend");
} else {
AN(d->vdir);

if (d->vdir->admin_health->health == 0)
d = NULL;
if (bo->director_req == NULL) {
VSLb(bo->vsl, SLT_FetchError, "No backend");
return (NULL);
}

return (d);
CHECK_OBJ(bo->director_req, DIRECTOR_MAGIC);
d = VRT_VDI_Resolve(ctx, bo->director_req);
if (d != NULL)
return (d);

VSLb(bo->vsl, SLT_FetchError,
"Director %s returned no backend", bo->director_req->vcl_name);
return (NULL);
}

/* Get a set of response headers -------------------------------------*/
Expand Down

0 comments on commit 136dde5

Please sign in to comment.