reverseproxy: Fix round robin data race (#4038)

This commit is contained in:
Matthew Holt
2021-02-25 09:41:52 -07:00
parent b54fa41239
commit ce5a0934a8
2 changed files with 4 additions and 4 deletions

View File

@ -221,8 +221,8 @@ func (r *RoundRobinSelection) Select(pool UpstreamPool, _ *http.Request, _ http.
return nil
}
for i := uint32(0); i < n; i++ {
atomic.AddUint32(&r.robin, 1)
host := pool[r.robin%n]
robin := atomic.AddUint32(&r.robin, 1)
host := pool[robin%n]
if host.Available() {
return host
}