From 98ae1a43af2cab6870b752173410207be568b047 Mon Sep 17 00:00:00 2001 From: balaji Date: Fri, 22 Mar 2024 17:04:50 +0530 Subject: [PATCH 1/3] fix unsubscription deadlock --- ethmonitor/ethmonitor.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ethmonitor/ethmonitor.go b/ethmonitor/ethmonitor.go index a081427b..e41ff826 100644 --- a/ethmonitor/ethmonitor.go +++ b/ethmonitor/ethmonitor.go @@ -986,10 +986,15 @@ func (m *Monitor) NumSubscribers() int { func (m *Monitor) UnsubscribeAll(err error) { m.mu.Lock() - defer m.mu.Unlock() + var subs []*subscriber for _, sub := range m.subscribers { + subs = append(subs, sub) + } + m.mu.Unlock() + + for _, sub := range subs { sub.err = err - sub.Unsubscribe() + sub.unsubscribe() } } From e231a73756fde2bdf1e820006035a61b35d46da7 Mon Sep 17 00:00:00 2001 From: balaji Date: Fri, 22 Mar 2024 18:54:40 +0530 Subject: [PATCH 2/3] minor --- ethmonitor/ethmonitor.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ethmonitor/ethmonitor.go b/ethmonitor/ethmonitor.go index e41ff826..788849dd 100644 --- a/ethmonitor/ethmonitor.go +++ b/ethmonitor/ethmonitor.go @@ -994,7 +994,7 @@ func (m *Monitor) UnsubscribeAll(err error) { for _, sub := range subs { sub.err = err - sub.unsubscribe() + sub.Unsubscribe() } } From 80851f7b4d5a1271320587c5e3ed11affd8b93b9 Mon Sep 17 00:00:00 2001 From: balaji Date: Fri, 22 Mar 2024 18:57:53 +0530 Subject: [PATCH 3/3] minor --- ethmonitor/ethmonitor.go | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/ethmonitor/ethmonitor.go b/ethmonitor/ethmonitor.go index 788849dd..49ec00df 100644 --- a/ethmonitor/ethmonitor.go +++ b/ethmonitor/ethmonitor.go @@ -987,9 +987,7 @@ func (m *Monitor) NumSubscribers() int { func (m *Monitor) UnsubscribeAll(err error) { m.mu.Lock() var subs []*subscriber - for _, sub := range m.subscribers { - subs = append(subs, sub) - } + subs = append(subs, m.subscribers...) m.mu.Unlock() for _, sub := range subs {