Commit 5c0551b8 authored by Nils Goroll's avatar Nils Goroll

add symbolic decision return from decide()

parent 0edaf31a
...@@ -62,6 +62,12 @@ parse_resolve_e(VCL_ENUM e) ...@@ -62,6 +62,12 @@ parse_resolve_e(VCL_ENUM e)
WRONG("illegal resolve enum"); WRONG("illegal resolve enum");
} }
enum decision_e {
D_NULL = 0,
D_CLUSTER,
D_REAL
};
struct vmod_cluster_cluster_param { struct vmod_cluster_cluster_param {
unsigned magic; unsigned magic;
#define VMOD_CLUSTER_CLUSTER_PARAM_MAGIC 0x3ba2a0d5 #define VMOD_CLUSTER_CLUSTER_PARAM_MAGIC 0x3ba2a0d5
...@@ -450,25 +456,31 @@ real_resolve(VRT_CTX, VCL_BACKEND r, enum resolve_e resolve) ...@@ -450,25 +456,31 @@ real_resolve(VRT_CTX, VCL_BACKEND r, enum resolve_e resolve)
} }
} }
static VCL_BACKEND static inline VCL_BACKEND
decide(VRT_CTX, decide(VRT_CTX, const struct vmod_cluster_cluster_param *pr,
const struct vmod_cluster_cluster_param *pr, enum resolve_e resolve) enum resolve_e resolve, enum decision_e *decision)
{ {
VCL_BACKEND r; VCL_BACKEND r;
if (pr->direct || if (pr->direct ||
(pr->uncacheable_direct && ctx->bo && (pr->uncacheable_direct && ctx->bo &&
(ctx->bo->do_pass || ctx->bo->uncacheable))) (ctx->bo->do_pass || ctx->bo->uncacheable)))
return (real_resolve(ctx, pr->real, resolve)); goto real;
AN(pr->cluster); AN(pr->cluster);
r = VRT_DirectorResolve(ctx, pr->cluster); r = VRT_DirectorResolve(ctx, pr->cluster);
if (r == NULL) if (r == NULL) {
if (decision != NULL)
*decision = D_NULL;
return (NULL); return (NULL);
}
if (cluster_blacklisted(pr, r)) if (cluster_blacklisted(pr, r))
return (real_resolve(ctx, pr->real, resolve)); goto real;
if (decision != NULL)
*decision = D_CLUSTER;
switch (resolve) { switch (resolve) {
case SHALLOW: case SHALLOW:
...@@ -479,13 +491,17 @@ decide(VRT_CTX, ...@@ -479,13 +491,17 @@ decide(VRT_CTX,
default: default:
WRONG("illegal resolve argument"); WRONG("illegal resolve argument");
} }
real:
if (decision != NULL)
*decision = D_REAL;
return (real_resolve(ctx, pr->real, resolve));
} }
static VCL_BACKEND v_matchproto_(vdi_resolve_f) static VCL_BACKEND v_matchproto_(vdi_resolve_f)
vmod_cluster_resolve(VRT_CTX, VCL_BACKEND dir) vmod_cluster_resolve(VRT_CTX, VCL_BACKEND dir)
{ {
return (decide(ctx, return (decide(ctx,
cluster_task_param_r(ctx, dir->priv), DEEP)); cluster_task_param_r(ctx, dir->priv), DEEP, NULL));
} }
static VCL_BACKEND static VCL_BACKEND
...@@ -505,7 +521,7 @@ cluster_choose(VRT_CTX, ...@@ -505,7 +521,7 @@ cluster_choose(VRT_CTX,
if (resolve == LAZY) if (resolve == LAZY)
return (vc->dir); return (vc->dir);
pr = cluster_task_param_r(ctx, vc); pr = cluster_task_param_r(ctx, vc);
return (decide(ctx, pr, resolve)); return (decide(ctx, pr, resolve, NULL));
} }
AN(modify); AN(modify);
...@@ -549,7 +565,7 @@ cluster_choose(VRT_CTX, ...@@ -549,7 +565,7 @@ cluster_choose(VRT_CTX,
if (resolve == LAZY) if (resolve == LAZY)
return (vc->dir); return (vc->dir);
return (decide(ctx, pr, resolve)); return (decide(ctx, pr, resolve, NULL));
} }
VCL_BACKEND VCL_BACKEND
......
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