summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancis Lavoie <lavofr@gmail.com>2023-10-11 12:04:28 -0400
committerGitHub <noreply@github.com>2023-10-11 16:04:28 +0000
commite8b8d4a8cdf116bf05345443e37a21ea7a37b8bb (patch)
tree3b7265d02db6e36aaddf49cf6b72f8bad40738a2
parenta8586b05aac81435f2a3d929a762fc994accbfdd (diff)
reverseproxy: Fix `least_conn` policy regression (#5862)
-rw-r--r--modules/caddyhttp/reverseproxy/selectionpolicies.go2
1 files changed, 1 insertions, 1 deletions
diff --git a/modules/caddyhttp/reverseproxy/selectionpolicies.go b/modules/caddyhttp/reverseproxy/selectionpolicies.go
index bc6de35..acb069a 100644
--- a/modules/caddyhttp/reverseproxy/selectionpolicies.go
+++ b/modules/caddyhttp/reverseproxy/selectionpolicies.go
@@ -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
}
}