From 13a6d413ac4c3d4521df97b2ad216ee622a4b506 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Sat, 25 Aug 2018 17:16:03 -0700 Subject: [PATCH] discovery: select on peer's QuitSignal to allow caller to unblock if disconnecting In this commit, we select on the peer's QuitSignal to allow the caller to unblock if the peer itself is disconnecting. With this change, we now ensure that it isn't possible for a peer to block on this method and prevent a graceful exit. --- discovery/gossiper.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/discovery/gossiper.go b/discovery/gossiper.go index 75daea1a..a698d60d 100644 --- a/discovery/gossiper.go +++ b/discovery/gossiper.go @@ -481,6 +481,11 @@ func (d *AuthenticatedGossiper) ProcessRemoteAnnouncement(msg lnwire.Message, select { case d.networkMsgs <- nMsg: + + // If the peer that sent us this error is quitting, then we don't need + // to send back an error and can return immediately. + case <-peer.QuitSignal(): + return nil case <-d.quit: nMsg.err <- ErrGossiperShuttingDown }