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.
This commit is contained in:
Olaoluwa Osuntokun 2018-08-25 17:16:03 -07:00
parent 19552b0dbf
commit 13a6d413ac
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21

@ -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
}