Resolve a race condition on `chainActive.Tip()` in initialization (introduced in #4379).

Signed-off-by: Daira Hopwood <daira@jacaranda.org>
This commit is contained in:
Daira Hopwood 2020-03-08 10:37:31 +00:00
parent 82e641f3cc
commit 74467f8f02
1 changed files with 11 additions and 4 deletions

View File

@ -1563,10 +1563,17 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
// original value of chainActive.Tip(), which corresponds with the wallet's
// view of the chaintip, is passed to ThreadNotifyWallets before the chain
// tip changes again.
boost::function<void()> threadnotifywallets = boost::bind(&ThreadNotifyWallets, chainActive.Tip());
threadGroup.create_thread(
boost::bind(&TraceThread<boost::function<void()>>, "txnotify", threadnotifywallets)
);
{
CBlockIndex *pindexLastTip;
{
LOCK(cs_main);
pindexLastTip = chainActive.Tip();
}
boost::function<void()> threadnotifywallets = boost::bind(&ThreadNotifyWallets, pindexLastTip);
threadGroup.create_thread(
boost::bind(&TraceThread<boost::function<void()>>, "txnotify", threadnotifywallets)
);
}
// ********************************************************* Step 9: data directory maintenance