Skip to content

Commit

Permalink
Websocket: Protect Setup() from races
Browse files Browse the repository at this point in the history
  • Loading branch information
gbjk committed Feb 16, 2024
1 parent 78a7e83 commit ebaa55d
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions exchanges/stream/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ func (w *Websocket) Setup(s *WebsocketSetup) error {
return errWebsocketSetupIsNil
}

w.m.Lock()
defer w.m.Unlock()

if w.IsInitialised() {
return fmt.Errorf("%s %w", w.exchangeName, errWebsocketAlreadyInitialised)
}
Expand Down

0 comments on commit ebaa55d

Please sign in to comment.