funding+peer: don't attempt to deliver messages if the peer is shutting down
This commit is contained in:
parent
d6f534cfa5
commit
0e510c8b5c
@ -2772,7 +2772,7 @@ func (f *fundingManager) handleInitFundingMsg(msg *initFundingMsg) {
|
||||
// sending new update messages to a channel before the channel is fully
|
||||
// opened.
|
||||
func (f *fundingManager) waitUntilChannelOpen(targetChan lnwire.ChannelID,
|
||||
quit <-chan struct{}) {
|
||||
quit <-chan struct{}) error {
|
||||
|
||||
f.barrierMtx.RLock()
|
||||
barrier, ok := f.newChanBarriers[targetChan]
|
||||
@ -2784,13 +2784,16 @@ func (f *fundingManager) waitUntilChannelOpen(targetChan lnwire.ChannelID,
|
||||
select {
|
||||
case <-barrier:
|
||||
case <-quit:
|
||||
return
|
||||
return ErrFundingManagerShuttingDown
|
||||
case <-f.quit:
|
||||
return
|
||||
return ErrFundingManagerShuttingDown
|
||||
}
|
||||
|
||||
fndgLog.Tracef("barrier for ChanID(%v) closed", targetChan)
|
||||
return nil
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// processFundingError sends a message to the fundingManager allowing it to
|
||||
|
11
peer.go
11
peer.go
@ -845,13 +845,18 @@ func newChanMsgStream(p *peer, cid lnwire.ChannelID) *msgStream {
|
||||
// to the other side, they immediately send a
|
||||
// channel update message, but we haven't yet
|
||||
// sent the channel to the channelManager.
|
||||
p.server.fundingMgr.waitUntilChannelOpen(
|
||||
err := p.server.fundingMgr.waitUntilChannelOpen(
|
||||
cid, p.quit,
|
||||
)
|
||||
if err != nil {
|
||||
// If we have a non-nil error, then the
|
||||
// funding manager is shutting down, s
|
||||
// we can exit here without attempting
|
||||
// to deliver the message.
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// TODO(roasbeef): only wait if not chan sync
|
||||
|
||||
// Dispatch the commitment update message to the proper active
|
||||
// goroutine dedicated to this channel.
|
||||
if chanLink == nil {
|
||||
|
Loading…
Reference in New Issue
Block a user