funding: add caller quit channel to waitUntilChannelOpen
In this commit, we add a caller quit channel to waitUntilChannelOpen. This ensures that the caller won't block forever if it needs to exit before the funding manager exits, or the channel barrier is actually closed.
This commit is contained in:
parent
e4e4a6ab58
commit
0b5a403fce
@ -2771,7 +2771,9 @@ func (f *fundingManager) handleInitFundingMsg(msg *initFundingMsg) {
|
|||||||
// waitUntilChannelOpen is designed to prevent other lnd subsystems from
|
// waitUntilChannelOpen is designed to prevent other lnd subsystems from
|
||||||
// sending new update messages to a channel before the channel is fully
|
// sending new update messages to a channel before the channel is fully
|
||||||
// opened.
|
// opened.
|
||||||
func (f *fundingManager) waitUntilChannelOpen(targetChan lnwire.ChannelID) {
|
func (f *fundingManager) waitUntilChannelOpen(targetChan lnwire.ChannelID,
|
||||||
|
quit <-chan struct{}) {
|
||||||
|
|
||||||
f.barrierMtx.RLock()
|
f.barrierMtx.RLock()
|
||||||
barrier, ok := f.newChanBarriers[targetChan]
|
barrier, ok := f.newChanBarriers[targetChan]
|
||||||
f.barrierMtx.RUnlock()
|
f.barrierMtx.RUnlock()
|
||||||
@ -2781,8 +2783,10 @@ func (f *fundingManager) waitUntilChannelOpen(targetChan lnwire.ChannelID) {
|
|||||||
|
|
||||||
select {
|
select {
|
||||||
case <-barrier:
|
case <-barrier:
|
||||||
case <-f.quit: // TODO(roasbeef): add timer?
|
case <-quit:
|
||||||
break
|
return
|
||||||
|
case <-f.quit:
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
fndgLog.Tracef("barrier for ChanID(%v) closed", targetChan)
|
fndgLog.Tracef("barrier for ChanID(%v) closed", targetChan)
|
||||||
|
Loading…
Reference in New Issue
Block a user