Skip to content

Commit 306f71b

Browse files
committed
scheduler: don't rely on boost interrupt on shutdown
Calling interrupt_all() will immediately stop the scheduler, so it's safe to invoke stop() beforehand, and this removes the reliance on boost to interrupt serviceQueue().
1 parent 97aadf9 commit 306f71b

File tree

3 files changed

+4
-0
lines changed

3 files changed

+4
-0
lines changed

src/init.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ void Shutdown(NodeContext& node)
206206

207207
// After everything has been shut down, but before things get flushed, stop the
208208
// CScheduler/checkqueue threadGroup
209+
if (node.scheduler) node.scheduler->stop();
209210
threadGroup.interrupt_all();
210211
threadGroup.join_all();
211212

src/test/txindex_tests.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,8 @@ BOOST_FIXTURE_TEST_CASE(txindex_initial_sync, TestChain100Setup)
7070
// shutdown sequence (c.f. Shutdown() in init.cpp)
7171
txindex.Stop();
7272

73+
// txindex job may be scheduled, so stop scheduler before destructing
74+
m_node.scheduler->stop();
7375
threadGroup.interrupt_all();
7476
threadGroup.join_all();
7577

src/test/util/setup_common.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ TestingSetup::TestingSetup(const std::string& chainName) : BasicTestingSetup(cha
140140

141141
TestingSetup::~TestingSetup()
142142
{
143+
if (m_node.scheduler) m_node.scheduler->stop();
143144
threadGroup.interrupt_all();
144145
threadGroup.join_all();
145146
GetMainSignals().FlushBackgroundCallbacks();

0 commit comments

Comments
 (0)