mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-03-04 09:48:19 +01:00
peer: before and after obtaining link for chan update, check quit signal
This commit is contained in:
parent
13a6d413ac
commit
f2db18733b
1 changed files with 20 additions and 2 deletions
22
peer.go
22
peer.go
|
@ -867,8 +867,17 @@ func newChanMsgStream(p *peer, cid lnwire.ChannelID) *msgStream {
|
|||
}
|
||||
}
|
||||
|
||||
// Dispatch the commitment update message to the proper active
|
||||
// goroutine dedicated to this channel.
|
||||
// In order to avoid unnecessarily delivering message
|
||||
// as the peer is exiting, we'll check quickly to see
|
||||
// if we need to exit.
|
||||
select {
|
||||
case <-p.quit:
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
// Dispatch the commitment update message to the proper
|
||||
// active goroutine dedicated to this channel.
|
||||
if chanLink == nil {
|
||||
link, err := p.server.htlcSwitch.GetLink(cid)
|
||||
if err != nil {
|
||||
|
@ -879,6 +888,15 @@ func newChanMsgStream(p *peer, cid lnwire.ChannelID) *msgStream {
|
|||
chanLink = link
|
||||
}
|
||||
|
||||
// In order to avoid unnecessarily delivering message
|
||||
// as the peer is exiting, we'll check quickly to see
|
||||
// if we need to exit.
|
||||
select {
|
||||
case <-p.quit:
|
||||
return
|
||||
default:
|
||||
}
|
||||
|
||||
chanLink.HandleChannelUpdate(msg)
|
||||
},
|
||||
)
|
||||
|
|
Loading…
Add table
Reference in a new issue