1
0
mirror of https://github.com/ipfs/kubo.git synced 2025-06-28 17:03:58 +08:00

avoid publishing if notification system has been shut down

(will deadlock)

License: MIT
Signed-off-by: Steven Allen <steven@stebalien.com>
This commit is contained in:
Steven Allen
2018-02-11 12:51:50 -08:00
parent 2baa3312d1
commit 1a37c0a870

View File

@ -36,6 +36,16 @@ type impl struct {
} }
func (ps *impl) Publish(block blocks.Block) { func (ps *impl) Publish(block blocks.Block) {
ps.wg.Add(1)
defer ps.wg.Done()
select {
case <-ps.cancel:
// Already shutdown, bail.
return
default:
}
ps.wrapped.Pub(block, block.Cid().KeyString()) ps.wrapped.Pub(block, block.Cid().KeyString())
} }