lnwallet: avoid goroutines waiting for channel open indefinitely blocking

Select over the quit channel in order to shutdown goroutines waiting
for funding txn confirmations. Without this we may leak goroutines
which are blocked forever if the process isn’t exiting when the walet
is signaled to shutdown.
This commit is contained in:
Olaoluwa Osuntokun 2016-02-02 18:40:27 -08:00
parent 20d471a766
commit 034cbef66d

View File

@ -993,8 +993,16 @@ func (l *LightningWallet) openChannelAfterConfirmations(res *ChannelReservation,
txid := res.partialState.FundingTx.TxSha()
l.chainNotifier.RegisterConfirmationsNotification(&txid, numConfs, trigger)
// Wait until the specified number of confirmations has been reached.
<-trigger.TriggerChan
// Wait until the specified number of confirmations has been reached,
// or the wallet signals a shutdown.
out:
select {
case <-trigger.TriggerChan:
break out
case <-l.quit:
res.chanOpen <- nil
return
}
// Finally, create and officially open the payment channel!
// TODO(roasbeef): CreationTime once tx is 'open'