[master] a469b3de5 round-robin director to consider all backends also when racing
Nils Goroll
nils.goroll at uplex.de
Mon Dec 7 14:31:07 UTC 2020
commit a469b3de517579d6da5f190cd3e853fa6a7d79e8
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Thu Dec 3 15:15:20 2020 +0100
round-robin director to consider all backends also when racing
When resolve requests race, we were not guaranteed to consider all
backends because we updated a shared nxt variable.
Fixes #3474
diff --git a/lib/libvmod_directors/round_robin.c b/lib/libvmod_directors/round_robin.c
index 74ec567e0..230bcb02e 100644
--- a/lib/libvmod_directors/round_robin.c
+++ b/lib/libvmod_directors/round_robin.c
@@ -80,14 +80,16 @@ vmod_rr_resolve(VRT_CTX, VCL_BACKEND dir)
CHECK_OBJ_NOTNULL(dir, DIRECTOR_MAGIC);
CAST_OBJ_NOTNULL(rr, dir->priv, VMOD_DIRECTORS_ROUND_ROBIN_MAGIC);
vdir_rdlock(rr->vd);
+ nxt = rr->nxt;
for (u = 0; u < rr->vd->n_backend; u++) {
- nxt = rr->nxt % rr->vd->n_backend;
- rr->nxt = nxt + 1;
be = rr->vd->backend[nxt];
+ nxt++;
+ nxt %= rr->vd->n_backend;
CHECK_OBJ_NOTNULL(be, DIRECTOR_MAGIC);
if (VRT_Healthy(ctx, be, NULL))
break;
}
+ rr->nxt = nxt;
vdir_unlock(rr->vd);
if (u == rr->vd->n_backend)
be = NULL;
More information about the varnish-commit
mailing list