Skip to content

Commit

Permalink
fix un subscription deadlock (#116)
Browse files Browse the repository at this point in the history
* fix unsubscription deadlock

* minor

* minor
  • Loading branch information
poonai authored Mar 22, 2024
1 parent a65c80f commit 3877127
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions ethmonitor/ethmonitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand Down

0 comments on commit 3877127

Please sign in to comment.