Commit 29cae579 authored by Chris O'Haver's avatar Chris O'Haver Committed by GitHub

plugin/loadbalance: More consistent shuffling (#4961)

* fix shuffling
Signed-off-by: default avatarChris O'Haver <cohaver@infoblox.com>

* shuffle each record once
Signed-off-by: default avatarChris O'Haver <cohaver@infoblox.com>
parent f6ffafe2
......@@ -61,13 +61,12 @@ func roundRobinShuffle(records []dns.RR) {
records[0], records[1] = records[1], records[0]
}
default:
for j := 0; j < l*(int(dns.Id())%4+1); j++ {
q := int(dns.Id()) % l
p := int(dns.Id()) % l
if q == p {
p = (p + 1) % l
for j := 0; j < l; j++ {
p := j + (int(dns.Id()) % (l-j))
if j == p {
continue
}
records[q], records[p] = records[p], records[q]
records[j], records[p] = records[p], records[j]
}
}
}
......
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