Avoid publishing on a channel if manager stopped
This commit is contained in:
parent
67b176a20b
commit
db56132d01
|
@ -74,3 +74,8 @@ _assets/compose/bootnode/keys
|
||||||
|
|
||||||
# do not vendor nested vendor/ dirs
|
# do not vendor nested vendor/ dirs
|
||||||
vendor/**/vendor
|
vendor/**/vendor
|
||||||
|
|
||||||
|
# nodejs package
|
||||||
|
|
||||||
|
package.json
|
||||||
|
package-lock.json
|
||||||
|
|
|
@ -84,6 +84,7 @@ type Manager struct {
|
||||||
periodicMemberPermissionsTasks sync.Map // stores `chan struct{}`
|
periodicMemberPermissionsTasks sync.Map // stores `chan struct{}`
|
||||||
torrentTasks map[string]metainfo.Hash
|
torrentTasks map[string]metainfo.Hash
|
||||||
historyArchiveDownloadTasks map[string]*HistoryArchiveDownloadTask
|
historyArchiveDownloadTasks map[string]*HistoryArchiveDownloadTask
|
||||||
|
stopped bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type openseaClient interface {
|
type openseaClient interface {
|
||||||
|
@ -313,6 +314,7 @@ func (m *Manager) Subscribe() chan *Subscription {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Manager) Start() error {
|
func (m *Manager) Start() error {
|
||||||
|
m.stopped = false
|
||||||
if m.ensVerifier != nil {
|
if m.ensVerifier != nil {
|
||||||
m.runENSVerificationLoop()
|
m.runENSVerificationLoop()
|
||||||
}
|
}
|
||||||
|
@ -347,6 +349,7 @@ func (m *Manager) runENSVerificationLoop() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Manager) Stop() error {
|
func (m *Manager) Stop() error {
|
||||||
|
m.stopped = true
|
||||||
close(m.quit)
|
close(m.quit)
|
||||||
for _, c := range m.subscriptions {
|
for _, c := range m.subscriptions {
|
||||||
close(c)
|
close(c)
|
||||||
|
@ -462,6 +465,9 @@ func (m *Manager) TorrentClientStarted() bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m *Manager) publish(subscription *Subscription) {
|
func (m *Manager) publish(subscription *Subscription) {
|
||||||
|
if m.stopped {
|
||||||
|
return
|
||||||
|
}
|
||||||
for _, s := range m.subscriptions {
|
for _, s := range m.subscriptions {
|
||||||
select {
|
select {
|
||||||
case s <- subscription:
|
case s <- subscription:
|
||||||
|
|
Loading…
Reference in New Issue