diff --git a/src/init.cpp b/src/init.cpp --- a/src/init.cpp +++ b/src/init.cpp @@ -156,6 +156,8 @@ static std::unique_ptr globalVerifyHandle; +static std::thread g_load_block; + static boost::thread_group threadGroup; void Interrupt(NodeContext &node) { @@ -240,10 +242,13 @@ StopTorControl(); // After everything has been shut down, but before things get flushed, stop - // the CScheduler/checkqueue threadGroup + // the CScheduler/checkqueue, threadGroup and load block thread. if (node.scheduler) { node.scheduler->stop(); } + if (g_load_block.joinable()) { + g_load_block.join(); + } threadGroup.interrupt_all(); threadGroup.join_all(); @@ -1367,7 +1372,6 @@ static void ThreadImport(const Config &config, ChainstateManager &chainman, std::vector vImportFiles, const ArgsManager &args) { - util::ThreadRename("loadblk"); ScheduleBatchPriority(); { @@ -2888,9 +2892,11 @@ vImportFiles.push_back(strFile); } - threadGroup.create_thread([=, &config, &chainman, &args] { - ThreadImport(config, chainman, vImportFiles, args); - }); + g_load_block = + std::thread(&TraceThread>, "loadblk", + [=, &config, &chainman, &args] { + ThreadImport(config, chainman, vImportFiles, args); + }); // Wait for genesis block to be processed {