[master] 3902e920c directors.shard: fix hole handling during recondiguration

Nils Goroll nils.goroll at uplex.de
Thu Mar 7 11:19:07 UTC 2019


commit 3902e920c8e922947078b1f3d1b0c21a0ae0560e
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 154595e8f..1483098ff 100644
--- a/lib/libvmod_directors/shard_cfg.c
+++ b/lib/libvmod_directors/shard_cfg.c
@@ -355,10 +355,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;
 }
 
@@ -434,6 +439,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