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:
parent
12538ea922
commit
326c62c6b5
6
peer.go
6
peer.go
@ -607,7 +607,11 @@ out:
|
|||||||
// queueMsg queues a new lnwire.Message to be eventually sent out on the
|
// queueMsg queues a new lnwire.Message to be eventually sent out on the
|
||||||
// wire.
|
// wire.
|
||||||
func (p *peer) queueMsg(msg lnwire.Message, doneChan chan struct{}) {
|
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
|
// ChannelSnapshots returns a slice of channel snapshots detailing all
|
||||||
|
Loading…
Reference in New Issue
Block a user