Skip to content

Commit 05714f9

Browse files
author
MarcoFalke
committed
Merge #11762: Avoid locking mutexes that are already held by the same thread
01a06d6 Avoid locking mutexes that are already held by the same thread (practicalswift) Pull request description: Avoid locking mutexes that are already held by the same thread. These are reentrant mutexes, but still no need to lock them more than once per thread :-) Tree-SHA512: e2fb85882e8800892fd8e8170f3c13128d6acfeb14d7b69fb9555f2b7ad0884fb201cf945b8144ffaf6fb1253c28af7c8c6c435319a7ae30ca003f28aa645a98
2 parents 10b9a81 + 01a06d6 commit 05714f9

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/txmempool.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,7 @@ void CTxMemPool::removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMem
542542
void CTxMemPool::removeConflicts(const CTransaction &tx)
543543
{
544544
// Remove transactions which depend on inputs of tx, recursively
545-
LOCK(cs);
545+
AssertLockHeld(cs);
546546
for (const CTxIn &txin : tx.vin) {
547547
auto it = mapNextTx.find(txin.prevout);
548548
if (it != mapNextTx.end()) {

src/txmempool.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -544,7 +544,7 @@ class CTxMemPool
544544

545545
void removeRecursive(const CTransaction &tx, MemPoolRemovalReason reason = MemPoolRemovalReason::UNKNOWN);
546546
void removeForReorg(const CCoinsViewCache *pcoins, unsigned int nMemPoolHeight, int flags);
547-
void removeConflicts(const CTransaction &tx);
547+
void removeConflicts(const CTransaction &tx) EXCLUSIVE_LOCKS_REQUIRED(cs);
548548
void removeForBlock(const std::vector<CTransactionRef>& vtx, unsigned int nBlockHeight);
549549

550550
void clear();

0 commit comments

Comments
 (0)