From f7025b57e76ba0e19df13efd86a0a6b3ff1a230d Mon Sep 17 00:00:00 2001 From: E Sequeira <5458743+geseq@users.noreply.github.com> Date: Mon, 17 Oct 2022 03:17:59 +0100 Subject: [PATCH] websocket: fix shutdown deadlock (#1059) * fix shutdown deadlock * cleanup * Update websocket.go --- exchanges/stream/websocket.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/exchanges/stream/websocket.go b/exchanges/stream/websocket.go index d4e6281f..310a3bc2 100644 --- a/exchanges/stream/websocket.go +++ b/exchanges/stream/websocket.go @@ -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 }