fix a race in tests

Signed-off-by: Dmitri Dolguikh <dmitri.external@netbird.io>
This commit is contained in:
Dmitri Dolguikh
2026-09-09 16:29:01 +02:00
parent e82d1140d6
commit 1b5568887d
2 changed files with 6 additions and 5 deletions
+3 -2
View File
@@ -2,6 +2,7 @@ package server
import (
"net/http"
"sync/atomic"
"time"
"github.com/coder/websocket"
@@ -59,7 +60,7 @@ func (p *Proxy) Handler() http.Handler {
type proxyHandler struct {
metrics MetricsRecorder
handler http.Handler
conn *wsConnAdapter
conn atomic.Pointer[wsConnAdapter]
headersReadTimeout time.Duration
}
@@ -91,7 +92,7 @@ func (ph *proxyHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
_ = serverConn.Close()
}()
ph.conn = serverConn // used in tests only
ph.conn.Store(serverConn) // used in tests only
log.Debugf("WebSocket proxy established: %s -> gRPC handler", r.RemoteAddr)