peer: before and after obtaining link for chan update, check quit signal

This commit is contained in:
Olaoluwa Osuntokun 2018-08-25 17:16:22 -07:00
parent 13a6d413ac
commit f2db18733b
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21

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)
},
)