peer: ensure queueMsg won't create deadlock if peer shutting down
This commit adds some additional measures to ensure that a call to queueMsg while the peer is shutting down won’t result in a potential deadlock. Currently, during shutdown the outgoingQueue channel is attempted to be cleared by he writeHandler, however adding an additional select statement serves as a mother layer of defense from nasty dead locks.
This commit is contained in:
1 file changed
+5
-1
@@ -607,7 +607,11 @@ out:
|
||||
// queueMsg queues a new lnwire.Message to be eventually sent out on the
|
||||
// wire.
|
||||
func (p *peer) queueMsg(msg lnwire.Message, doneChan chan struct{}) {
|
||||
p.outgoingQueue <- outgoinMsg{msg, doneChan}
|
||||
select {
|
||||
case p.outgoingQueue <- outgoinMsg{msg, doneChan}:
|
||||
case <-p.quit:
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// ChannelSnapshots returns a slice of channel snapshots detailing all
|
||||
|
||||
Reference in new issue
Block a user