mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-02-23 14:40:30 +01:00
server: fix deadlock in sendToPeer at peer shutdown
This commit fixes a deadlock that could occur when a peer disconnected during a call to sentToPeer. In This particular case, a message would successfully be queued, the peer would shutdown, and we would block waiting for an error to be returned on the message's error channel, which would deadlock. This fixes that by also checking for peer shutdown.
This commit is contained in:
parent
3b986b4c14
commit
db8b4cad4a
1 changed files with 2 additions and 0 deletions
|
@ -958,6 +958,8 @@ func (s *server) sendToPeer(target *btcec.PublicKey,
|
||||||
select {
|
select {
|
||||||
case err := <-errChan:
|
case err := <-errChan:
|
||||||
return err
|
return err
|
||||||
|
case <-targetPeer.quit:
|
||||||
|
return fmt.Errorf("peer shutting down")
|
||||||
case <-s.quit:
|
case <-s.quit:
|
||||||
return ErrServerShuttingDown
|
return ErrServerShuttingDown
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue