mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 22:50:59 +01:00
Close minor startup race between main and scheduler threads
Don't schedule class PeerManagerImpl's background tasks from its constructor, but instead do that from a separate method, StartScheduledTasks(), that can be called later at the end of startup, after other things, such as the active chain, are initialzed.
This commit is contained in:
@@ -1180,7 +1180,7 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
||||
|
||||
assert(!node.peerman);
|
||||
node.peerman = PeerManager::make(chainparams, *node.connman, *node.addrman, node.banman.get(),
|
||||
*node.scheduler, chainman, *node.mempool, ignores_incoming_txs);
|
||||
chainman, *node.mempool, ignores_incoming_txs);
|
||||
RegisterValidationInterface(node.peerman.get());
|
||||
|
||||
// sanitize comments per BIP-0014, format user agent and check total size
|
||||
@@ -1789,6 +1789,8 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
||||
banman->DumpBanlist();
|
||||
}, DUMP_BANS_INTERVAL);
|
||||
|
||||
if (node.peerman) node.peerman->StartScheduledTasks(*node.scheduler);
|
||||
|
||||
#if HAVE_SYSTEM
|
||||
StartupNotify(args);
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user