Skip to content

Commit 0d699fc

Browse files
committed
fix locking issue with new mempool limiting
Current master crashes on OSX with an exception: "boost: mutex lock failed in pthread_mutex_lock: Invalid argument"
1 parent 867d6c9 commit 0d699fc

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

src/txmempool.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,7 @@ void CTxMemPoolEntry::UpdateState(int64_t modifySize, CAmount modifyFee, int64_t
309309
CTxMemPool::CTxMemPool(const CFeeRate& _minReasonableRelayFee) :
310310
nTransactionsUpdated(0)
311311
{
312-
clear();
312+
_clear(); //lock free clear
313313

314314
// Sanity checks off by default for performance, because otherwise
315315
// accepting transactions becomes O(N^2) where N is the number
@@ -546,9 +546,8 @@ void CTxMemPool::removeForBlock(const std::vector<CTransaction>& vtx, unsigned i
546546
blockSinceLastRollingFeeBump = true;
547547
}
548548

549-
void CTxMemPool::clear()
549+
void CTxMemPool::_clear()
550550
{
551-
LOCK(cs);
552551
mapLinks.clear();
553552
mapTx.clear();
554553
mapNextTx.clear();
@@ -560,6 +559,12 @@ void CTxMemPool::clear()
560559
++nTransactionsUpdated;
561560
}
562561

562+
void CTxMemPool::clear()
563+
{
564+
LOCK(cs);
565+
_clear();
566+
}
567+
563568
void CTxMemPool::check(const CCoinsViewCache *pcoins) const
564569
{
565570
if (!fSanityCheck)

src/txmempool.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,7 @@ class CTxMemPool
375375
void removeForBlock(const std::vector<CTransaction>& vtx, unsigned int nBlockHeight,
376376
std::list<CTransaction>& conflicts, bool fCurrentEstimate = true);
377377
void clear();
378+
void _clear(); //lock free
378379
void queryHashes(std::vector<uint256>& vtxid);
379380
void pruneSpent(const uint256& hash, CCoins &coins);
380381
unsigned int GetTransactionsUpdated() const;

0 commit comments

Comments
 (0)