From a11a8693ae636b9f580bdee22005811b0b255720 Mon Sep 17 00:00:00 2001 From: Conner Fromknecht Date: Mon, 6 May 2019 14:44:54 -0700 Subject: [PATCH] peer: break sendMessage on server quit This commit modifies sendMessage to break on the server's quit channel, which allows synchronous callers of SendMessage or SendLazyMessage to receive an error during server shutdown which can be independent of a particular peer's shutdown. As of https://github.com/lightningnetwork/lnd/pull/2916, all replies made by gossip syncers were modified to be synchronous. In certain cases, This would prevent the syncers from shutting down promptly, as they would try to offload a batch a of messages that could not be aborted. Now, an error will be propagated back to the caller, allowing them to detect the error condition, and reevaluate their own quit signals, releasing any waitgrouped goroutines and permitting a quick shutdown. --- peer.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/peer.go b/peer.go index 71b06fc4..37096c5f 100644 --- a/peer.go +++ b/peer.go @@ -2502,6 +2502,8 @@ func (p *peer) sendMessage(sync, priority bool, msgs ...lnwire.Message) error { return err case <-p.quit: return lnpeer.ErrPeerExiting + case <-p.server.quit: + return lnpeer.ErrPeerExiting } }