[6.0] 1e3cfe582 directors.shard: fix hole handling during recondiguration
Reza Naghibi
reza at naghibi.com
Wed Aug 19 13:17:06 UTC 2020
commit 1e3cfe582bbbcf1cee1cbb021eb4486a170e8192
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Thu Mar 7 11:51:57 2019 +0100
directors.shard: fix hole handling during recondiguration
diff --git a/lib/libvmod_directors/shard_cfg.c b/lib/libvmod_directors/shard_cfg.c
index ab6d70380..56127e28b 100644
--- a/lib/libvmod_directors/shard_cfg.c
+++ b/lib/libvmod_directors/shard_cfg.c
@@ -353,10 +353,15 @@ shardcfg_backend_lookup(const struct backend_reconfig *re,
unsigned i, max = re->shardd->n_backend + re->hole_n;
const struct shard_backend *bb = re->shardd->backend;
- for (i = 0; i < max; i++)
+ if (max > 0)
+ AN(bb);
+
+ for (i = 0; i < max; i++) {
+ if (bb[i].backend == NULL)
+ continue; // hole
if (!shardcfg_backend_cmp(b, &bb[i]))
return &bb[i];
-
+ }
return NULL;
}
@@ -432,6 +437,8 @@ shardcfg_backend_del(struct backend_reconfig *re,
struct shard_backend * const bb = re->shardd->backend;
for (i = 0; i < max; i++) {
+ if (bb[i].backend == NULL)
+ continue; // hole
if (shardcfg_backend_del_cmp(spec, &bb[i]))
continue;
More information about the varnish-commit
mailing list