Skip to content

Commit f2db187

Browse files
committed
peer: before and after obtaining link for chan update, check quit signal
1 parent 13a6d41 commit f2db187

File tree

1 file changed

+20
-2
lines changed

1 file changed

+20
-2
lines changed

peer.go

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -867,8 +867,17 @@ func newChanMsgStream(p *peer, cid lnwire.ChannelID) *msgStream {
867867
}
868868
}
869869

870-
// Dispatch the commitment update message to the proper active
871-
// goroutine dedicated to this channel.
870+
// In order to avoid unnecessarily delivering message
871+
// as the peer is exiting, we'll check quickly to see
872+
// if we need to exit.
873+
select {
874+
case <-p.quit:
875+
return
876+
default:
877+
}
878+
879+
// Dispatch the commitment update message to the proper
880+
// active goroutine dedicated to this channel.
872881
if chanLink == nil {
873882
link, err := p.server.htlcSwitch.GetLink(cid)
874883
if err != nil {
@@ -879,6 +888,15 @@ func newChanMsgStream(p *peer, cid lnwire.ChannelID) *msgStream {
879888
chanLink = link
880889
}
881890

891+
// In order to avoid unnecessarily delivering message
892+
// as the peer is exiting, we'll check quickly to see
893+
// if we need to exit.
894+
select {
895+
case <-p.quit:
896+
return
897+
default:
898+
}
899+
882900
chanLink.HandleChannelUpdate(msg)
883901
},
884902
)

0 commit comments

Comments
 (0)