Skip to content

Commit c652392

Browse files
committed
Release the lock when writing and reacquire it just after writing
1 parent a5bcf56 commit c652392

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

websocket.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,12 @@ func (p *WebSocketProxy) HandleWebSocket(w http.ResponseWriter, r *http.Request)
7575
log.Printf("Failed to marshal unsubscribe message: %v", err)
7676
continue
7777
}
78+
79+
// Release the lock before writing to the upstream WebSocket
80+
p.mu.Unlock()
7881
err = p.upstream.Write(context.Background(), websocket.MessageText, messageBytes)
82+
p.mu.Lock() // Reacquire the lock after writing
83+
7984
if err != nil {
8085
log.Printf("Failed to forward unsubscribe message to upstream: %v", err)
8186
}

0 commit comments

Comments
 (0)