Fast and extensible multi-platform HTTP/1-2-3 web server with automatic HTTPS
Mirrored from https://github.com/Slazee/caddy.git
Synced Nov 14, 05:15 UTC
reverseproxy: Fix round robin data race (#4038)
Matthew Holt committed
Feb 25, 2021 at 09:41 UTC
ce5a0934a89aabf1bc145ed0100df5f889b7dd74
2 files changed
+4
-4
modules/caddyhttp/reverseproxy/reverseproxy.go
+2
-2
@@ -368,8 +368,8 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request, next caddyht
368
reqHost := r.Host
369
reqHeader := r.Header
370
defer func() {
371
- r.Host = reqHost
372
- r.Header = reqHeader
371
+ r.Host = reqHost // TODO: data race, see #4038
372
+ r.Header = reqHeader // TODO: data race, see #4038
373
}()
374
375
start := time.Now()
modules/caddyhttp/reverseproxy/selectionpolicies.go
+2
-2
@@ -221,8 +221,8 @@ func (r *RoundRobinSelection) Select(pool UpstreamPool, _ *http.Request, _ http.
221
return nil
222
}
223
for i := uint32(0); i < n; i++ {
224
- atomic.AddUint32(&r.robin, 1)
225
- host := pool[r.robin%n]
224
+ robin := atomic.AddUint32(&r.robin, 1)
225
+ host := pool[robin%n]
226
if host.Available() {
227
return host
228
}