Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1839,10 +1839,16 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
vImportFiles.push_back(fs::PathFromString(strFile));
}

node.background_init_thread = std::thread(&util::TraceThread, "initload", [=, &chainman, &args, &node] {
node.background_init_thread = std::thread(&util::TraceThread, "initload", [=, &chainman, &args, &kernel_notifications, &node] {
ScheduleBatchPriority();
// Import blocks and ActivateBestChain()
ImportBlocks(chainman, vImportFiles);
// An interrupted import may return without activating genesis. Wake
// the init thread's genesis wait, which is otherwise only notified
// on blockTip, and that never fires when the import was interrupted
// before activating genesis. This wakeup lets the wait observe the
// shutdown request.
WITH_LOCK(kernel_notifications.m_tip_block_mutex, kernel_notifications.m_tip_block_cv.notify_all());
if (args.GetBoolArg("-stopafterblockimport", DEFAULT_STOPAFTERBLOCKIMPORT)) {
LogPrintf("Stopping after block import\n");
if (!(Assert(node.shutdown_request))()) {
Expand Down
7 changes: 5 additions & 2 deletions test/functional/feature_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ def check_clean_start():
node.wait_for_rpc_connection()
assert_equal(200, node.getblockcount())

reindex_log_line = b'Reindexing block file blk00000.dat'
lines_to_terminate_after = [
b'Validating signatures for all blocks',
b'scheduler thread start',
Expand All @@ -85,17 +86,19 @@ def check_clean_start():
]
if self.is_wallet_compiled():
lines_to_terminate_after.append(b'Verifying wallet')
lines_to_terminate_after.append(reindex_log_line)

args = ['-txindex=1', '-blockfilterindex=1', '-coinstatsindex=1']
for terminate_line in lines_to_terminate_after:
self.log.info(f"Starting node and will exit after line {terminate_line}")
with node.busy_wait_for_debug_log([terminate_line]):
extra_args = ['-reindex'] if terminate_line == reindex_log_line else [*args]
if platform.system() == 'Windows':
# CREATE_NEW_PROCESS_GROUP is required in order to be able
# to terminate the child without terminating the test.
node.start(extra_args=args, creationflags=subprocess.CREATE_NEW_PROCESS_GROUP)
node.start(extra_args=extra_args, creationflags=subprocess.CREATE_NEW_PROCESS_GROUP)
else:
node.start(extra_args=args)
node.start(extra_args=extra_args)
self.log.debug("Terminating node after terminate line was found")
sigterm_node()

Expand Down