mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-03 09:56:38 -05:00
Make CCheckQueue
destructor stop worker threads
This commit is contained in:
parent
be4ff3060b
commit
d03eaacbcf
9 changed files with 2 additions and 29 deletions
|
@ -61,7 +61,6 @@ static void CCheckQueueSpeedPrevectorJob(benchmark::Bench& bench)
|
|||
// it is done explicitly here for clarity
|
||||
control.Wait();
|
||||
});
|
||||
queue.StopWorkerThreads();
|
||||
ECC_Stop();
|
||||
}
|
||||
BENCHMARK(CCheckQueueSpeedPrevectorJob, benchmark::PriorityLevel::HIGH);
|
||||
|
|
|
@ -290,7 +290,6 @@ epilogue:
|
|||
// dereferencing and UB.
|
||||
scheduler.stop();
|
||||
if (chainman.m_thread_load.joinable()) chainman.m_thread_load.join();
|
||||
chainman.StopScriptCheckWorkerThreads();
|
||||
|
||||
GetMainSignals().FlushBackgroundCallbacks();
|
||||
{
|
||||
|
|
|
@ -179,24 +179,16 @@ public:
|
|||
}
|
||||
}
|
||||
|
||||
//! Stop all of the worker threads.
|
||||
void StopWorkerThreads() EXCLUSIVE_LOCKS_REQUIRED(!m_mutex)
|
||||
~CCheckQueue()
|
||||
{
|
||||
WITH_LOCK(m_mutex, m_request_stop = true);
|
||||
m_worker_cv.notify_all();
|
||||
for (std::thread& t : m_worker_threads) {
|
||||
t.join();
|
||||
}
|
||||
m_worker_threads.clear();
|
||||
WITH_LOCK(m_mutex, m_request_stop = false);
|
||||
}
|
||||
|
||||
bool HasThreads() const { return !m_worker_threads.empty(); }
|
||||
|
||||
~CCheckQueue()
|
||||
{
|
||||
assert(m_worker_threads.empty());
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -268,10 +268,9 @@ void Shutdown(NodeContext& node)
|
|||
StopTorControl();
|
||||
|
||||
// After everything has been shut down, but before things get flushed, stop the
|
||||
// CScheduler/checkqueue, scheduler and load block thread.
|
||||
// scheduler and load block thread.
|
||||
if (node.scheduler) node.scheduler->stop();
|
||||
if (node.chainman && node.chainman->m_thread_load.joinable()) node.chainman->m_thread_load.join();
|
||||
if (node.chainman) node.chainman->StopScriptCheckWorkerThreads();
|
||||
|
||||
// After the threads that potentially access these pointers have been stopped,
|
||||
// destruct and reset all to nullptr.
|
||||
|
|
|
@ -176,7 +176,6 @@ static void Correct_Queue_range(std::vector<size_t> range)
|
|||
BOOST_REQUIRE(control.Wait());
|
||||
BOOST_REQUIRE_EQUAL(FakeCheckCheckCompletion::n_calls, i);
|
||||
}
|
||||
small_queue->StopWorkerThreads();
|
||||
}
|
||||
|
||||
/** Test that 0 checks is correct
|
||||
|
@ -240,7 +239,6 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_Catches_Failure)
|
|||
BOOST_REQUIRE(success);
|
||||
}
|
||||
}
|
||||
fail_queue->StopWorkerThreads();
|
||||
}
|
||||
// Test that a block validation which fails does not interfere with
|
||||
// future blocks, ie, the bad state is cleared.
|
||||
|
@ -262,7 +260,6 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_Recovers_From_Failure)
|
|||
BOOST_REQUIRE(r != end_fails);
|
||||
}
|
||||
}
|
||||
fail_queue->StopWorkerThreads();
|
||||
}
|
||||
|
||||
// Test that unique checks are actually all called individually, rather than
|
||||
|
@ -294,7 +291,6 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_UniqueCheck)
|
|||
}
|
||||
BOOST_REQUIRE(r);
|
||||
}
|
||||
queue->StopWorkerThreads();
|
||||
}
|
||||
|
||||
|
||||
|
@ -325,7 +321,6 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_Memory)
|
|||
}
|
||||
BOOST_REQUIRE_EQUAL(MemoryCheck::fake_allocated_memory, 0U);
|
||||
}
|
||||
queue->StopWorkerThreads();
|
||||
}
|
||||
|
||||
// Test that a new verification cannot occur until all checks
|
||||
|
@ -361,7 +356,6 @@ BOOST_AUTO_TEST_CASE(test_CheckQueue_FrozenCleanup)
|
|||
// Wait for control to finish
|
||||
t0.join();
|
||||
BOOST_REQUIRE(!fails);
|
||||
queue->StopWorkerThreads();
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -553,7 +553,6 @@ BOOST_AUTO_TEST_CASE(test_big_witness_transaction)
|
|||
|
||||
bool controlCheck = control.Wait();
|
||||
assert(controlCheck);
|
||||
scriptcheckqueue.StopWorkerThreads();
|
||||
}
|
||||
|
||||
SignatureData CombineSignatures(const CMutableTransaction& input1, const CMutableTransaction& input2, const CTransactionRef tx)
|
||||
|
|
|
@ -193,7 +193,6 @@ ChainTestingSetup::ChainTestingSetup(const ChainType chainType, const std::vecto
|
|||
ChainTestingSetup::~ChainTestingSetup()
|
||||
{
|
||||
if (m_node.scheduler) m_node.scheduler->stop();
|
||||
m_node.chainman->StopScriptCheckWorkerThreads();
|
||||
GetMainSignals().FlushBackgroundCallbacks();
|
||||
GetMainSignals().UnregisterBackgroundSignalScheduler();
|
||||
m_node.connman.reset();
|
||||
|
|
|
@ -2047,11 +2047,6 @@ DisconnectResult Chainstate::DisconnectBlock(const CBlock& block, const CBlockIn
|
|||
return fClean ? DISCONNECT_OK : DISCONNECT_UNCLEAN;
|
||||
}
|
||||
|
||||
void ChainstateManager::StopScriptCheckWorkerThreads()
|
||||
{
|
||||
m_script_check_queue.StopWorkerThreads();
|
||||
}
|
||||
|
||||
/**
|
||||
* Threshold condition checker that triggers when unknown versionbits are seen on the network.
|
||||
*/
|
||||
|
@ -5754,8 +5749,6 @@ ChainstateManager::ChainstateManager(const util::SignalInterrupt& interrupt, Opt
|
|||
|
||||
ChainstateManager::~ChainstateManager()
|
||||
{
|
||||
StopScriptCheckWorkerThreads();
|
||||
|
||||
LOCK(::cs_main);
|
||||
|
||||
m_versionbitscache.Clear();
|
||||
|
|
|
@ -1246,7 +1246,6 @@ public:
|
|||
std::optional<int> GetSnapshotBaseHeight() const EXCLUSIVE_LOCKS_REQUIRED(::cs_main);
|
||||
|
||||
CCheckQueue<CScriptCheck>& GetCheckQueue() { return m_script_check_queue; }
|
||||
void StopScriptCheckWorkerThreads();
|
||||
|
||||
~ChainstateManager();
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue