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:
Olaoluwa Osuntokun committed 2018-08-25 17:30:04 -07:00
1 parent e4e4a6ab58
commit 0b5a403fce
1 file changed
+7 -3
+7 -3
View File
@@ -2771,7 +2771,9 @@ func (f *fundingManager) handleInitFundingMsg(msg *initFundingMsg) {
// waitUntilChannelOpen is designed to prevent other lnd subsystems from
// sending new update messages to a channel before the channel is fully
// opened.
func (f *fundingManager) waitUntilChannelOpen(targetChan lnwire.ChannelID) {
func (f *fundingManager) waitUntilChannelOpen(targetChan lnwire.ChannelID,
quit <-chan struct{}) {
f.barrierMtx.RLock()
barrier, ok := f.newChanBarriers[targetChan]
f.barrierMtx.RUnlock()
@@ -2781,8 +2783,10 @@ func (f *fundingManager) waitUntilChannelOpen(targetChan lnwire.ChannelID) {
select {
case <-barrier:
case <-f.quit: // TODO(roasbeef): add timer?
break
case <-quit:
return
case <-f.quit:
return
}
fndgLog.Tracef("barrier for ChanID(%v) closed", targetChan)