Commit 69d1e52d authored by Nils Goroll's avatar Nils Goroll Committed by Reza Naghibi

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
parent 4fe90267
......@@ -69,14 +69,16 @@ vmod_rr_resolve(const struct director *dir, struct worker *wrk,
CHECK_OBJ_NOTNULL(bo, BUSYOBJ_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 (be->healthy(be, bo, NULL))
break;
}
rr->nxt = nxt;
vdir_unlock(rr->vd);
if (u == rr->vd->n_backend)
be = NULL;
......
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