Skip to content

Commit

Permalink
fix locking issue with new mempool limiting
Browse files Browse the repository at this point in the history
Current master crashes on OSX with an exception: "boost: mutex lock failed in pthread_mutex_lock: Invalid argument"
  • Loading branch information
jonasschnelli committed Oct 26, 2015
1 parent 867d6c9 commit 0d699fc
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/txmempool.cpp
Expand Up @@ -309,7 +309,7 @@ void CTxMemPoolEntry::UpdateState(int64_t modifySize, CAmount modifyFee, int64_t
CTxMemPool::CTxMemPool(const CFeeRate& _minReasonableRelayFee) :
nTransactionsUpdated(0)
{
clear();
_clear(); //lock free clear

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

void CTxMemPool::clear()
void CTxMemPool::_clear()
{
LOCK(cs);
mapLinks.clear();
mapTx.clear();
mapNextTx.clear();
Expand All @@ -560,6 +559,12 @@ void CTxMemPool::clear()
++nTransactionsUpdated;
}

void CTxMemPool::clear()
{
LOCK(cs);
_clear();
}

void CTxMemPool::check(const CCoinsViewCache *pcoins) const
{
if (!fSanityCheck)
Expand Down
1 change: 1 addition & 0 deletions src/txmempool.h
Expand Up @@ -375,6 +375,7 @@ class CTxMemPool
void removeForBlock(const std::vector<CTransaction>& vtx, unsigned int nBlockHeight,
std::list<CTransaction>& conflicts, bool fCurrentEstimate = true);
void clear();
void _clear(); //lock free
void queryHashes(std::vector<uint256>& vtxid);
void pruneSpent(const uint256& hash, CCoins &coins);
unsigned int GetTransactionsUpdated() const;
Expand Down

0 comments on commit 0d699fc

Please sign in to comment.