websocket: fix shutdown deadlock (#1059)

* fix shutdown deadlock

* cleanup

* Update websocket.go
This commit is contained in:
E Sequeira
2022-10-17 03:17:59 +01:00
committed by GitHub
parent 9acbdbf203
commit f7025b57e7

View File

@@ -568,6 +568,8 @@ func (w *Websocket) trafficMonitor() {
w.trafficTimeout)
}
trafficTimer.Stop()
w.setTrafficMonitorRunning(false)
w.Wg.Done() // without this the w.Shutdown() call below will deadlock
if !w.IsConnecting() && w.IsConnected() {
err := w.Shutdown()
if err != nil {
@@ -576,8 +578,7 @@ func (w *Websocket) trafficMonitor() {
w.exchangeName, err)
}
}
w.setTrafficMonitorRunning(false)
w.Wg.Done()
return
}