aboutsummaryrefslogtreecommitdiff
path: root/src/rpc
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2019-07-02 16:28:53 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2019-07-02 16:29:08 +0200
commitc6e42f1ca9c8a2eeb315c68e66dc7e9e8153882a (patch)
tree62c039e5bb218a1b4a1699be0a9a7e6514a2792f /src/rpc
parent6c21a801f3df4942d09d5a33d3dab04807f7bb37 (diff)
parentfa2b083c3feb0522baf652045efa6b73458761a3 (diff)
downloadbitcoin-c6e42f1ca9c8a2eeb315c68e66dc7e9e8153882a.tar.xz
Merge #14193: validation: Add missing mempool locks
fa2b083c3feb0522baf652045efa6b73458761a3 [test] Add test to check mempool consistency in case of reorgs (MarcoFalke) fabeb1f613653a8c1560e4a093a9b6b7a069b60b validation: Add missing mempool locks (MarcoFalke) fa0c9dbf9156d64a4b9bff858da97825369a9134 txpool: 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 ACK fa2b083c3feb0522baf652045efa6b73458761a3 ryanofsky: utACK fa2b083c3feb0522baf652045efa6b73458761a3 [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
Diffstat (limited to 'src/rpc')
-rw-r--r--src/rpc/mining.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp
index 477f05f46c..86b0845738 100644
--- a/src/rpc/mining.cpp
+++ b/src/rpc/mining.cpp
@@ -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);