mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 23:18:14 +01:00
Merge #18458: net: Add missing cs_vNodes lock
fa369651c5net: Add missing cs_vNodes lock (MarcoFalke) Pull request description: Fixes #18457 ACKs for top commit: promag: Code review ACKfa369651c5. laanwj: ACKfa369651c5Tree-SHA512: 60d7000f2f3d480bb0953ce27a0020763e7102da16a0006b619e0a236cfc33cbd4f83d870e9f0546639711cd877c1f9808d419184bbc153bb328885417e0066c
This commit is contained in:
15
src/init.cpp
15
src/init.cpp
@@ -197,7 +197,20 @@ void Shutdown(NodeContext& node)
|
||||
// Because these depend on each-other, we make sure that neither can be
|
||||
// using the other before destroying them.
|
||||
if (node.peer_logic) UnregisterValidationInterface(node.peer_logic.get());
|
||||
if (node.connman) node.connman->Stop();
|
||||
// Follow the lock order requirements:
|
||||
// * CheckForStaleTipAndEvictPeers locks cs_main before indirectly calling GetExtraOutboundCount
|
||||
// which locks cs_vNodes.
|
||||
// * ProcessMessage locks cs_main and g_cs_orphans before indirectly calling ForEachNode which
|
||||
// locks cs_vNodes.
|
||||
// * CConnman::Stop calls DeleteNode, which calls FinalizeNode, which locks cs_main and calls
|
||||
// EraseOrphansFor, which locks g_cs_orphans.
|
||||
//
|
||||
// Thus the implicit locking order requirement is: (1) cs_main, (2) g_cs_orphans, (3) cs_vNodes.
|
||||
if (node.connman) {
|
||||
node.connman->StopThreads();
|
||||
LOCK2(::cs_main, ::g_cs_orphans);
|
||||
node.connman->StopNodes();
|
||||
}
|
||||
|
||||
StopTorControl();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user