diff options
author | Simão Gomes Viana <[email protected]> | 2021-04-29 18:52:22 +0200 |
---|---|---|
committer | GitHub <[email protected]> | 2021-04-29 10:52:22 -0600 |
commit | 90175571698d7cb0e4184d257a425f0bd11c713d (patch) | |
tree | cfa7d28aa0491fc38547e640ff458a21c1c5f3cd /modules/caddyhttp/reverseproxy/selectionpolicies.go | |
parent | 3a1e81dbf6587d2e886529d55e7a02eabeaa7c47 (diff) | |
download | caddy-90175571698d7cb0e4184d257a425f0bd11c713d.tar.gz caddy-90175571698d7cb0e4184d257a425f0bd11c713d.zip |
reverseproxy: fix hash selection policy (#4137)
* caddyhttp: reverseproxy: fix hash selection policy
Fixes: #4135
Test: go test './...' -count=1
* caddyhttp: reverseproxy: add test to catch #4135
If you revert the last commit, the test will fail.
Diffstat (limited to 'modules/caddyhttp/reverseproxy/selectionpolicies.go')
-rw-r--r-- | modules/caddyhttp/reverseproxy/selectionpolicies.go | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/modules/caddyhttp/reverseproxy/selectionpolicies.go b/modules/caddyhttp/reverseproxy/selectionpolicies.go index 357ee33a9..001f7f806 100644 --- a/modules/caddyhttp/reverseproxy/selectionpolicies.go +++ b/modules/caddyhttp/reverseproxy/selectionpolicies.go @@ -523,8 +523,7 @@ func hostByHashing(pool []*Upstream, s string) *Upstream { } index := hash(s) % poolLen for i := uint32(0); i < poolLen; i++ { - index += i - upstream := pool[index%poolLen] + upstream := pool[(index+i)%poolLen] if upstream.Available() { return upstream } |