reverseproxy: Fix least_conn policy regression (#5862)

This commit is contained in:
Francis Lavoie 2023-10-11 12:04:28 -04:00 committed by GitHub
parent a8586b05aa
commit e8b8d4a8cd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -269,7 +269,7 @@ func (LeastConnSelection) Select(pool UpstreamPool, _ *http.Request, _ http.Resp
// sample: https://en.wikipedia.org/wiki/Reservoir_sampling
if numReqs == leastReqs {
count++
if count > 1 || (weakrand.Int()%count) == 0 { //nolint:gosec
if count == 1 || (weakrand.Int()%count) == 0 { //nolint:gosec
bestHost = host
}
}