Mailing List Archive

[master] 5b79a6580 Diffentiate "no backend" from "none resolved" in VDI_Resolve()
commit 5b79a65807d63668dd00f0bca9151dd9651d6271
Author: Nils Goroll <nils.goroll@uplex.de>
Date: Wed May 13 18:16:59 2020 +0200

Diffentiate "no backend" from "none resolved" in VDI_Resolve()

recover a minor improvement from #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 #2860 #3311

diff --git a/bin/varnishd/cache/cache_director.c b/bin/varnishd/cache/cache_director.c
index 3e6902031..1aa4388d5 100644
--- a/bin/varnishd/cache/cache_director.c
+++ b/bin/varnishd/cache/cache_director.c
@@ -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 -------------------------------------*/
_______________________________________________
varnish-commit mailing list
varnish-commit@varnish-cache.org
https://www.varnish-cache.org/lists/mailman/listinfo/varnish-commit