[master] b8290db Close a race in the round robin director - for real now
Nils Goroll
nils.goroll at uplex.de
Fri Jul 28 22:12:10 CEST 2017
commit b8290db410c511f58d4c14d6daa9f4af3de5711b
Author: Nils Goroll <nils.goroll at uplex.de>
Date: Fri Jul 28 22:01:26 2017 +0200
Close a race in the round robin director - for real now
The previous code allowed the compiler to re-read nxt from
rr->nxt which could have been incremented cocurrently.
Fixes #2378
diff --git a/lib/libvmod_directors/round_robin.c b/lib/libvmod_directors/round_robin.c
index 59f7332..3932938 100644
--- a/lib/libvmod_directors/round_robin.c
+++ b/lib/libvmod_directors/round_robin.c
@@ -70,9 +70,9 @@ vmod_rr_resolve(const struct director *dir, struct worker *wrk,
CAST_OBJ_NOTNULL(rr, dir->priv, VMOD_DIRECTORS_ROUND_ROBIN_MAGIC);
vdir_rdlock(rr->vd);
for (u = 0; u < rr->vd->n_backend; u++) {
- nxt = rr->nxt %= rr->vd->n_backend;
+ nxt = rr->nxt % rr->vd->n_backend;
+ rr->nxt = nxt + 1;
be = rr->vd->backend[nxt];
- rr->nxt++;
CHECK_OBJ_NOTNULL(be, DIRECTOR_MAGIC);
if (be->healthy(be, bo, NULL))
break;
More information about the varnish-commit
mailing list