mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-05-29 23:33:33 +02:00
Merge #14193: validation: Add missing mempool locks
fa2b083c3f[test] Add test to check mempool consistency in case of reorgs (MarcoFalke)fabeb1f613validation: Add missing mempool locks (MarcoFalke)fa0c9dbf91txpool: Make nTransactionsUpdated atomic (MarcoFalke) Pull request description: Take the mempool read lock during reorgs, so that we don't accidentally read an inconsistent mempool. ACKs for top commit: laanwj: code review ACKfa2b083c3fryanofsky: utACKfa2b083c3f[EDIT: was ~e284e422e75189794e24fe482819d8b1407857c3~, from bad copy and paste]. Changes since last review: rebase after #15976, adding vTxHashes lock annotation, adding new commit dropping mempool lock for nTransactionsUpdated and making it atomic to avoid deadlock between mempool lock and g_best_block_mutex Tree-SHA512: cfe7777993589087753e000e3736d79d320dca412383fb77b56bef8946a04049722bf888c11b6f722adf677165185c7e58b4a269f7c5fa25e84dda375f6c8a7d
This commit is contained in:
@@ -469,7 +469,7 @@ static UniValue getblocktemplate(const JSONRPCRequest& request)
|
||||
nTransactionsUpdatedLastLP = nTransactionsUpdatedLast;
|
||||
}
|
||||
|
||||
// Release the wallet and main lock while waiting
|
||||
// Release lock while waiting
|
||||
LEAVE_CRITICAL_SECTION(cs_main);
|
||||
{
|
||||
checktxtime = std::chrono::steady_clock::now() + std::chrono::minutes(1);
|
||||
@@ -480,6 +480,7 @@ static UniValue getblocktemplate(const JSONRPCRequest& request)
|
||||
if (g_best_block_cv.wait_until(lock, checktxtime) == std::cv_status::timeout)
|
||||
{
|
||||
// Timeout: Check transactions for update
|
||||
// without holding ::mempool.cs to avoid deadlocks
|
||||
if (mempool.GetTransactionsUpdated() != nTransactionsUpdatedLastLP)
|
||||
break;
|
||||
checktxtime += std::chrono::seconds(10);
|
||||
|
||||
Reference in New Issue
Block a user