From 98b0c51b5ff339a12999dc9345a2b2df3f15d944 Mon Sep 17 00:00:00 2001 From: Ethan Buchman Date: Fri, 1 Jun 2018 23:59:35 -0400 Subject: [PATCH] fix possible mempool deadlock --- mempool/mempool.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/mempool/mempool.go b/mempool/mempool.go index 938fb2a7..438da729 100644 --- a/mempool/mempool.go +++ b/mempool/mempool.go @@ -72,8 +72,8 @@ type Mempool struct { rechecking int32 // for re-checking filtered txs on Update() recheckCursor *clist.CElement // next expected response recheckEnd *clist.CElement // re-checking stops here - notifiedTxsAvailable bool // true if fired on txsAvailable for this height - txsAvailable chan int64 // fires the next height once for each height, when the mempool is not empty + notifiedTxsAvailable bool + txsAvailable chan int64 // fires the next height once for each height, when the mempool is not empty // Keep a cache of already-seen txs. // This reduces the pressure on the proxyApp. @@ -328,8 +328,12 @@ func (mem *Mempool) notifyTxsAvailable() { panic("notified txs available but mempool is empty!") } if mem.txsAvailable != nil && !mem.notifiedTxsAvailable { + select { + case mem.txsAvailable <- mem.height + 1: + default: + } + mem.notifiedTxsAvailable = true - mem.txsAvailable <- mem.height + 1 } }