From db56132d01d122f25b144eac88a9a7d872bf1ca2 Mon Sep 17 00:00:00 2001 From: Andrea Maria Piana Date: Thu, 29 Jun 2023 09:21:48 +0000 Subject: [PATCH] Avoid publishing on a channel if manager stopped --- .gitignore | 5 +++++ protocol/communities/manager.go | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/.gitignore b/.gitignore index 1f65b4e2d..0b53a8ac8 100644 --- a/.gitignore +++ b/.gitignore @@ -74,3 +74,8 @@ _assets/compose/bootnode/keys # do not vendor nested vendor/ dirs vendor/**/vendor + +# nodejs package + +package.json +package-lock.json diff --git a/protocol/communities/manager.go b/protocol/communities/manager.go index d85d51e3e..3cef1940b 100644 --- a/protocol/communities/manager.go +++ b/protocol/communities/manager.go @@ -84,6 +84,7 @@ type Manager struct { periodicMemberPermissionsTasks sync.Map // stores `chan struct{}` torrentTasks map[string]metainfo.Hash historyArchiveDownloadTasks map[string]*HistoryArchiveDownloadTask + stopped bool } type openseaClient interface { @@ -313,6 +314,7 @@ func (m *Manager) Subscribe() chan *Subscription { } func (m *Manager) Start() error { + m.stopped = false if m.ensVerifier != nil { m.runENSVerificationLoop() } @@ -347,6 +349,7 @@ func (m *Manager) runENSVerificationLoop() { } func (m *Manager) Stop() error { + m.stopped = true close(m.quit) for _, c := range m.subscriptions { close(c) @@ -462,6 +465,9 @@ func (m *Manager) TorrentClientStarted() bool { } func (m *Manager) publish(subscription *Subscription) { + if m.stopped { + return + } for _, s := range m.subscriptions { select { case s <- subscription: