From ce5a0934a89aabf1bc145ed0100df5f889b7dd74 Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Thu, 25 Feb 2021 09:41:52 -0700 Subject: reverseproxy: Fix round robin data race (#4038) --- modules/caddyhttp/reverseproxy/selectionpolicies.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'modules/caddyhttp/reverseproxy/selectionpolicies.go') diff --git a/modules/caddyhttp/reverseproxy/selectionpolicies.go b/modules/caddyhttp/reverseproxy/selectionpolicies.go index e86e97e..dacfd11 100644 --- a/modules/caddyhttp/reverseproxy/selectionpolicies.go +++ b/modules/caddyhttp/reverseproxy/selectionpolicies.go @@ -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 } -- cgit v1.2.3