Skip to content

Commit

Permalink
Websocket: Set disconnected earlier in Shutdown
Browse files Browse the repository at this point in the history
This caused a possible race where state is still connected, but we start
to trigger interested actors via ShutdownC and Wait.
They may check state and then call Shutdown again, such as
trafficMonitor
  • Loading branch information
gbjk committed Feb 23, 2024
1 parent d79f8fb commit 9aca06e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion exchanges/stream/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -477,10 +477,11 @@ func (w *Websocket) Shutdown() error {
w.subscriptions = subscriptionMap{}
w.subscriptionMutex.Unlock()

w.setState(disconnected)

close(w.ShutdownC)
w.Wg.Wait()
w.ShutdownC = make(chan struct{})
w.setState(disconnected)
if w.verbose {
log.Debugf(log.WebsocketMgr, "%v websocket: completed websocket shutdown", w.exchangeName)
}
Expand Down

0 comments on commit 9aca06e

Please sign in to comment.