From 2082f1141aed4e4e24a8c53f548ca8e026a8065e Mon Sep 17 00:00:00 2001 From: lane-c-wagner Date: Fri, 23 Apr 2021 08:03:13 -0600 Subject: [PATCH] only close channels if they aren't already --- channel.go | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/channel.go b/channel.go index 84bc086..4524f5a 100644 --- a/channel.go +++ b/channel.go @@ -66,8 +66,18 @@ func (chManager *channelManager) startNotifyCancelOrClosed() { chManager.logger.Printf("successfully reconnected to amqp server after cancel") chManager.notifyCancelOrClose <- errors.New(err) } - close(notifyCancelChan) - close(notifyCloseChan) + + // these channels can be closed by amqp + select { + case <-notifyCloseChan: + default: + close(notifyCloseChan) + } + select { + case <-notifyCancelChan: + default: + close(notifyCancelChan) + } } // reconnectWithBackoff continuously attempts to reconnect with an