From 7be039adec5eb63e3b9cc0ce69b45fee253e2683 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Wed, 30 Aug 2017 20:26:10 -0700 Subject: [PATCH] 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. --- fundingmanager.go | 2 ++ utxonursery.go | 1 + 2 files changed, 3 insertions(+) diff --git a/fundingmanager.go b/fundingmanager.go index 821d210e..d3a540f7 100644 --- a/fundingmanager.go +++ b/fundingmanager.go @@ -1210,6 +1210,8 @@ func (f *fundingManager) waitForFundingWithTimeout(completeChan *channeldb.OpenC return } + defer epochClient.Cancel() + waitingDoneChan := make(chan struct{}) cancelChan := make(chan struct{}) diff --git a/utxonursery.go b/utxonursery.go index 4d016cc0..8ccd9aca 100644 --- a/utxonursery.go +++ b/utxonursery.go @@ -321,6 +321,7 @@ func (u *utxoNursery) incubator(newBlockChan *chainntnfs.BlockEpochEvent, startingHeight uint32) { defer u.wg.Done() + defer newBlockChan.Cancel() currentHeight := startingHeight out: