Skip to content

Commit

Permalink
fix unsubscription deadlock
Browse files Browse the repository at this point in the history
  • Loading branch information
poonai committed Mar 22, 2024
1 parent a65c80f commit 98ae1a4
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions ethmonitor/ethmonitor.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}

Expand Down

0 comments on commit 98ae1a4

Please sign in to comment.