Skip to content

Commit 5fd4836

Browse files
committed
init: change shutdown order of load block thread and scheduler
This avoids situations during a reindex in which shutdown doesn't finish since SyncWithValidationInterfaceQueue is called by the load block thread when the scheduler is already stopped.
1 parent 33af14e commit 5fd4836

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

src/init.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -296,10 +296,11 @@ void Shutdown(NodeContext& node)
296296

297297
StopTorControl();
298298

299+
if (node.chainman && node.chainman->m_thread_load.joinable()) node.chainman->m_thread_load.join();
299300
// After everything has been shut down, but before things get flushed, stop the
300-
// scheduler and load block thread.
301+
// the scheduler. After this point, SyncWithValidationInterfaceQueue() should not be called anymore
302+
// as this would prevent the shutdown from completing.
301303
if (node.scheduler) node.scheduler->stop();
302-
if (node.chainman && node.chainman->m_thread_load.joinable()) node.chainman->m_thread_load.join();
303304

304305
// After the threads that potentially access these pointers have been stopped,
305306
// destruct and reset all to nullptr.

0 commit comments

Comments
 (0)