aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAnthony Towns <aj@erisian.com.au>2020-02-28 12:02:10 +1000
committerAnthony Towns <aj@erisian.com.au>2020-03-06 23:13:31 +1000
commit306f71b4eb4a0fd8e64f47dc008bc235b80b13d9 (patch)
treeda839e0cea4ea52524ca04e0c0c9cc71b5add687 /src
parent97aadf98d0b890e09eff45535fa13a663f27334d (diff)
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().
Diffstat (limited to 'src')
-rw-r--r--src/init.cpp1
-rw-r--r--src/test/txindex_tests.cpp2
-rw-r--r--src/test/util/setup_common.cpp1
3 files changed, 4 insertions, 0 deletions
diff --git a/src/init.cpp b/src/init.cpp
index 14d489617c..a637aac4d2 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -206,6 +206,7 @@ void Shutdown(NodeContext& node)
// After everything has been shut down, but before things get flushed, stop the
// CScheduler/checkqueue threadGroup
+ if (node.scheduler) node.scheduler->stop();
threadGroup.interrupt_all();
threadGroup.join_all();
diff --git a/src/test/txindex_tests.cpp b/src/test/txindex_tests.cpp
index 6474711cad..3550a02316 100644
--- a/src/test/txindex_tests.cpp
+++ b/src/test/txindex_tests.cpp
@@ -70,6 +70,8 @@ BOOST_FIXTURE_TEST_CASE(txindex_initial_sync, TestChain100Setup)
// shutdown sequence (c.f. Shutdown() in init.cpp)
txindex.Stop();
+ // txindex job may be scheduled, so stop scheduler before destructing
+ m_node.scheduler->stop();
threadGroup.interrupt_all();
threadGroup.join_all();
diff --git a/src/test/util/setup_common.cpp b/src/test/util/setup_common.cpp
index fc736bc3a1..53eb9ff43b 100644
--- a/src/test/util/setup_common.cpp
+++ b/src/test/util/setup_common.cpp
@@ -140,6 +140,7 @@ TestingSetup::TestingSetup(const std::string& chainName) : BasicTestingSetup(cha
TestingSetup::~TestingSetup()
{
+ if (m_node.scheduler) m_node.scheduler->stop();
threadGroup.interrupt_all();
threadGroup.join_all();
GetMainSignals().FlushBackgroundCallbacks();