mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-04 01:36:24 +01: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:
parent
49eeabf2a4
commit
2def3fc542
1 changed files with 7 additions and 1 deletions
|
@ -3195,7 +3195,13 @@ func (s *server) NotifyWhenOnline(peerKey [33]byte,
|
||||||
select {
|
select {
|
||||||
case <-peer.ActiveSignal():
|
case <-peer.ActiveSignal():
|
||||||
case <-peer.QuitSignal():
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue