From cb3a1fd095bafb9aeb6b10ed83d73930b9681ec7 Mon Sep 17 00:00:00 2001 From: Jae Kwon Date: Mon, 12 Oct 2015 16:49:46 -0700 Subject: [PATCH] Fixed a blockchain pool goroutine-leak bug --- blockchain/pool.go | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/blockchain/pool.go b/blockchain/pool.go index 79c428e1c..b7293b883 100644 --- a/blockchain/pool.go +++ b/blockchain/pool.go @@ -162,14 +162,18 @@ func (pool *BlockPool) PopRequest() { pool.mtx.Lock() // Lock defer pool.mtx.Unlock() - /* The block can disappear at any time, due to removePeer(). - if r := pool.requesters[pool.height]; r == nil || r.block == nil { - PanicSanity("PopRequest() requires a valid block") + if r := pool.requesters[pool.height]; r != nil { + /* The block can disappear at any time, due to removePeer(). + if r := pool.requesters[pool.height]; r == nil || r.block == nil { + PanicSanity("PopRequest() requires a valid block") + } + */ + r.Stop() + delete(pool.requesters, pool.height) + pool.height++ + } else { + PanicSanity(Fmt("Expected requester to pop, got nothing at height %v", pool.height)) } - */ - - delete(pool.requesters, pool.height) - pool.height++ } // Invalidates the block at pool.height,