From 1cdc3eb41f352bbb1b6207ae6480670ea6c2c5d0 Mon Sep 17 00:00:00 2001 From: Ivan Kozlovic Date: Tue, 21 May 2019 09:28:59 -0600 Subject: [PATCH] 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 --- server/gateway.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/server/gateway.go b/server/gateway.go index ea78c2a9..51d9b279 100644 --- a/server/gateway.go +++ b/server/gateway.go @@ -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 }