Better randomize solicited Gateway URLs

Shuffle the array created when iterating through the gateways URLs
map since map iteration may not be well randomized with small maps.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
This commit is contained in:
Ivan Kozlovic
2019-05-21 09:28:59 -06:00
parent 0144e27afd
commit 1cdc3eb41f

View File

@@ -1304,6 +1304,10 @@ func (g *gatewayCfg) getURLs() []*url.URL {
a = append(a, u)
}
g.RUnlock()
// Map iteration is random, but not that good with small maps.
rand.Shuffle(len(a), func(i, j int) {
a[i], a[j] = a[j], a[i]
})
return a
}