Skip to content

Commit

Permalink
init: change shutdown order of load block thread and scheduler
Browse files Browse the repository at this point in the history
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.

Github-Pull: bitcoin#30435
Rebased-From: 5fd4836
  • Loading branch information
mzumsande authored and fanquake committed Jul 17, 2024
1 parent ab42206 commit 05192ba
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,10 +296,11 @@ void Shutdown(NodeContext& node)

StopTorControl();

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

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

0 comments on commit 05192ba

Please sign in to comment.