From 38771270b7741919a72f53dbd8e31fdb198a43de Mon Sep 17 00:00:00 2001 From: Poonai Date: Fri, 22 Mar 2024 20:07:58 +0530 Subject: [PATCH] fix un subscription deadlock (#116) * fix unsubscription deadlock * minor * minor --- ethmonitor/ethmonitor.go | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/ethmonitor/ethmonitor.go b/ethmonitor/ethmonitor.go index a081427b..49ec00df 100644 --- a/ethmonitor/ethmonitor.go +++ b/ethmonitor/ethmonitor.go @@ -986,8 +986,11 @@ func (m *Monitor) NumSubscribers() int { func (m *Monitor) UnsubscribeAll(err error) { m.mu.Lock() - defer m.mu.Unlock() - for _, sub := range m.subscribers { + var subs []*subscriber + subs = append(subs, m.subscribers...) + m.mu.Unlock() + + for _, sub := range subs { sub.err = err sub.Unsubscribe() }