@cryptotaxi247 / kubo / commits / 1a37c0a87

avoid publishing if notification system has been shut down

(will deadlock) License: MIT Signed-off-by: Steven Allen <steven@stebalien.com>

Steven Allen committed Feb 11, 2018 at 12:51 UTC 1a37c0a870357a71c0b21d8f8e8fe2d28d0aefa8
1 file changed +10
exchange/bitswap/notifications/notifications.go
+10
@@ -36,6 +36,16 @@ type impl struct {
36 }
37
38 func (ps *impl) Publish(block blocks.Block) {
39 + ps.wg.Add(1)
40 + defer ps.wg.Done()
41 +
42 + select {
43 + case <-ps.cancel:
44 + // Already shutdown, bail.
45 + return
46 + default:
47 + }
48 +
49 ps.wrapped.Pub(block, block.Cid().KeyString())
50 }
51