mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-07-23 19:35:28 +02:00
server.go: add peerChan to peerConnectedListeners in NotifyWhenOnline
This fixes a bug where a caller would: - call NotifyWhenOnline and pass in a channel - the server's mutex is held and the pubStr is checked in peersByPub - the peer object is in the peersByPub map - the peer object has its quit channel closed - QuitSignal is called in the select statement, and the function returns - the caller is still waiting for the channel to be sent on forever since it was never sent on or added to the peerConnectedListeners slice. This patch fixes the above bug by adding the channel to the peerConnectedListeners slice if the QuitSignal select case is called.
This commit is contained in:
@@ -3195,7 +3195,13 @@ func (s *server) NotifyWhenOnline(peerKey [33]byte,
|
||||
select {
|
||||
case <-peer.ActiveSignal():
|
||||
case <-peer.QuitSignal():
|
||||
// The peer quit so we'll just return.
|
||||
// The peer quit, so we'll add the channel to the slice
|
||||
// and return.
|
||||
s.mu.Lock()
|
||||
s.peerConnectedListeners[pubStr] = append(
|
||||
s.peerConnectedListeners[pubStr], peerChan,
|
||||
)
|
||||
s.mu.Unlock()
|
||||
return
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user