diff options
author | Matthew Holt <mholt@users.noreply.github.com> | 2021-02-25 09:41:52 -0700 |
---|---|---|
committer | Matthew Holt <mholt@users.noreply.github.com> | 2021-02-25 09:41:52 -0700 |
commit | ce5a0934a89aabf1bc145ed0100df5f889b7dd74 (patch) | |
tree | 6346dcea84752e27deede2e16c31fc52d2e5dabb /modules/caddyhttp | |
parent | b54fa4123975195c721ff5a5c0b43c4622009676 (diff) |
reverseproxy: Fix round robin data race (#4038)
Diffstat (limited to 'modules/caddyhttp')
-rw-r--r-- | modules/caddyhttp/reverseproxy/reverseproxy.go | 4 | ||||
-rw-r--r-- | modules/caddyhttp/reverseproxy/selectionpolicies.go | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/modules/caddyhttp/reverseproxy/reverseproxy.go b/modules/caddyhttp/reverseproxy/reverseproxy.go index d2d01e6..9da509f 100644 --- a/modules/caddyhttp/reverseproxy/reverseproxy.go +++ b/modules/caddyhttp/reverseproxy/reverseproxy.go @@ -368,8 +368,8 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyht reqHost := r.Host reqHeader := r.Header defer func() { - r.Host = reqHost - r.Header = reqHeader + r.Host = reqHost // TODO: data race, see #4038 + r.Header = reqHeader // TODO: data race, see #4038 }() start := time.Now() 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 } |