Commit cbad0fbe authored by Nils Goroll's avatar Nils Goroll

avoid the evil alloca

parent 7fc2003e
...@@ -388,14 +388,15 @@ vmod_cluster_resolve(VRT_CTX, VCL_BACKEND dir) ...@@ -388,14 +388,15 @@ vmod_cluster_resolve(VRT_CTX, VCL_BACKEND dir)
cluster_task_param_r(ctx, dir->priv))); cluster_task_param_r(ctx, dir->priv)));
} }
#define be_task_param_l(pl, pr, ctx, vc, arg) do { \ #define be_task_param_l(pl, pr, ctx, vc, arg, spc) \
do { \
if ((pl) != NULL) { \ if ((pl) != NULL) { \
(void)0; \ (void)0; \
} else if ((arg)->resolve == vmod_enum_LAZY) { \ } else if ((arg)->resolve == vmod_enum_LAZY) { \
(pr) = (pl) = cluster_task_param_l( \ (pr) = (pl) = cluster_task_param_l( \
(ctx), (vc), (pr)->nblack + 1); \ (ctx), (vc), (pr)->nblack + 1); \
} else { \ } else { \
(pl) = alloca(param_sz((pr), (pr)->nblack + 1)); \ (pl) = (void *)(spc); \
memcpy((pl), (pr), param_sz((pr), (pr)->nblack)); \ memcpy((pl), (pr), param_sz((pr), (pr)->nblack)); \
(pl)->spcblack = (pr)->nblack + 1; \ (pl)->spcblack = (pr)->nblack + 1; \
(pr) = (pl); \ (pr) = (pl); \
...@@ -409,7 +410,7 @@ vmod_cluster_backend(VRT_CTX, ...@@ -409,7 +410,7 @@ vmod_cluster_backend(VRT_CTX,
{ {
int modify = arg->valid_deny || arg->valid_real || int modify = arg->valid_deny || arg->valid_real ||
arg->valid_uncacheable_direct; arg->valid_uncacheable_direct;
const struct vmod_cluster_cluster_param *pr = NULL; const struct vmod_cluster_cluster_param *pr;
struct vmod_cluster_cluster_param *pl = NULL; struct vmod_cluster_cluster_param *pl = NULL;
if (! modify) { if (! modify) {
...@@ -426,20 +427,23 @@ vmod_cluster_backend(VRT_CTX, ...@@ -426,20 +427,23 @@ vmod_cluster_backend(VRT_CTX,
" can not be called here"); " can not be called here");
return NULL; return NULL;
} }
pr = cluster_task_param_r(ctx, vc); pr = cluster_task_param_r(ctx, vc);
char pstk[param_sz(pr, pr->nblack + 1)];
if (arg->valid_deny && arg->deny != NULL && if (arg->valid_deny && arg->deny != NULL &&
! cluster_blacklisted(pr, arg->deny)) { ! cluster_blacklisted(pr, arg->deny)) {
be_task_param_l(pl, pr, ctx, vc, arg); be_task_param_l(pl, pr, ctx, vc, arg, pstk);
cluster_blacklist_add(pl, arg->deny); cluster_blacklist_add(pl, arg->deny);
} }
if (arg->valid_real && if (arg->valid_real &&
pr->real != arg->real) { pr->real != arg->real) {
be_task_param_l(pl, pr, ctx, vc, arg); be_task_param_l(pl, pr, ctx, vc, arg, pstk);
pl->real = arg->real; pl->real = arg->real;
} }
if (arg->valid_uncacheable_direct && if (arg->valid_uncacheable_direct &&
pr->uncacheable_direct != arg->valid_uncacheable_direct) { pr->uncacheable_direct != arg->valid_uncacheable_direct) {
be_task_param_l(pl, pr, ctx, vc, arg); be_task_param_l(pl, pr, ctx, vc, arg, pstk);
pl->uncacheable_direct = arg->valid_uncacheable_direct; pl->uncacheable_direct = arg->valid_uncacheable_direct;
} }
if (arg->resolve == vmod_enum_LAZY) if (arg->resolve == vmod_enum_LAZY)
......
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