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:
Larry Ruane
2021-07-28 16:18:53 -06:00
parent 4b1fb50def
commit 703b1e612a
5 changed files with 21 additions and 11 deletions

View File

@@ -197,7 +197,7 @@ TestingSetup::TestingSetup(const std::string& chainName, const std::vector<const
m_node.banman = std::make_unique<BanMan>(m_args.GetDataDirBase() / "banlist", nullptr, DEFAULT_MISBEHAVING_BANTIME);
m_node.connman = std::make_unique<CConnman>(0x1337, 0x1337, *m_node.addrman); // Deterministic randomness for tests.
m_node.peerman = PeerManager::make(chainparams, *m_node.connman, *m_node.addrman,
m_node.banman.get(), *m_node.scheduler, *m_node.chainman,
m_node.banman.get(), *m_node.chainman,
*m_node.mempool, false);
{
CConnman::Options options;