Fixed a blockchain pool goroutine-leak bug

This commit is contained in:
Jae Kwon 2015-10-12 16:49:46 -07:00
parent fd9f816050
commit cb3a1fd095

View File

@ -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,