mirror of
https://github.com/lightningnetwork/lnd.git
synced 2024-11-19 09:53:54 +01:00
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:
parent
20d471a766
commit
034cbef66d
@ -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'
|
||||
|
Loading…
Reference in New Issue
Block a user