multi: ensure that BlockEpoch clients are cancelled

This commit fixes a prior goroutine leak that could result in a node
having thousands of goroutines, particularly due to many concurrent
channel fundings. We now ensure that for each BlockEpoch client
created, we ensure that the client is cancelled once the creating
grouting exits.
This commit is contained in:
Olaoluwa Osuntokun 2017-08-30 20:26:10 -07:00
parent 916ab454c1
commit 7be039adec
No known key found for this signature in database
GPG Key ID: 9CC5B105D03521A2
2 changed files with 3 additions and 0 deletions

View File

@ -1210,6 +1210,8 @@ func (f *fundingManager) waitForFundingWithTimeout(completeChan *channeldb.OpenC
return
}
defer epochClient.Cancel()
waitingDoneChan := make(chan struct{})
cancelChan := make(chan struct{})

View File

@ -321,6 +321,7 @@ func (u *utxoNursery) incubator(newBlockChan *chainntnfs.BlockEpochEvent,
startingHeight uint32) {
defer u.wg.Done()
defer newBlockChan.Cancel()
currentHeight := startingHeight
out: