From af6e6f0b4378d6aaa3827afee1c3f4dac004f813 Mon Sep 17 00:00:00 2001 From: Steven Allen Date: Sun, 11 Feb 2018 12:51:50 -0800 Subject: [PATCH] avoid publishing if notification system has been shut down (will deadlock) License: MIT Signed-off-by: Steven Allen --- notifications/notifications.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/notifications/notifications.go b/notifications/notifications.go index defea70..9a6f10b 100644 --- a/notifications/notifications.go +++ b/notifications/notifications.go @@ -36,6 +36,16 @@ type impl struct { } 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()) } -- GitLab