mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 06:28:31 +01:00
Merge bitcoin/bitcoin#26762: bugfix: Make CCheckQueue RAII-styled (attempt 2)
5b3ea5fa2erefactor: Move `{MAX,DEFAULT}_SCRIPTCHECK_THREADS` constants (Hennadii Stepanov)6e17b31680refactor: Make `CCheckQueue` non-copyable and non-movable explicitly (Hennadii Stepanov)8111e74653refactor: Drop unneeded declaration (Hennadii Stepanov)9cf89f7a5brefactor: Make `CCheckQueue` constructor start worker threads (Hennadii Stepanov)d03eaacbcfMake `CCheckQueue` destructor stop worker threads (Hennadii Stepanov)be4ff3060bMove global `scriptcheckqueue` into `ChainstateManager` class (Hennadii Stepanov) Pull request description: This PR: - makes `CCheckQueue` RAII-styled - gets rid of the global `scriptcheckqueue` - fixes https://github.com/bitcoin/bitcoin/issues/25448 The previous attempt was in https://github.com/bitcoin/bitcoin/pull/18731. ACKs for top commit: martinus: ACK5b3ea5fa2eachow101: ACK5b3ea5fa2eTheCharlatan: ACK5b3ea5fa2eTree-SHA512: 45cca846e7ed107e3930149f0b616ddbaf2648d6cde381f815331b861b5d67ab39e154883ae174b8abb1dae485bc904318c50c51e5d6b46923d89de51c5eadb0
This commit is contained in:
21
src/init.cpp
21
src/init.cpp
@@ -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();
|
||||
StopScriptCheckWorkerThreads();
|
||||
|
||||
// After the threads that potentially access these pointers have been stopped,
|
||||
// destruct and reset all to nullptr.
|
||||
@@ -1114,24 +1113,6 @@ bool AppInitMain(NodeContext& node, interfaces::BlockAndHeaderTipInfo* tip_info)
|
||||
return InitError(strprintf(_("Unable to allocate memory for -maxsigcachesize: '%s' MiB"), args.GetIntArg("-maxsigcachesize", DEFAULT_MAX_SIG_CACHE_BYTES >> 20)));
|
||||
}
|
||||
|
||||
int script_threads = args.GetIntArg("-par", DEFAULT_SCRIPTCHECK_THREADS);
|
||||
if (script_threads <= 0) {
|
||||
// -par=0 means autodetect (number of cores - 1 script threads)
|
||||
// -par=-n means "leave n cores free" (number of cores - n - 1 script threads)
|
||||
script_threads += GetNumCores();
|
||||
}
|
||||
|
||||
// Subtract 1 because the main thread counts towards the par threads
|
||||
script_threads = std::max(script_threads - 1, 0);
|
||||
|
||||
// Number of script-checking threads <= MAX_SCRIPTCHECK_THREADS
|
||||
script_threads = std::min(script_threads, MAX_SCRIPTCHECK_THREADS);
|
||||
|
||||
LogPrintf("Script verification uses %d additional threads\n", script_threads);
|
||||
if (script_threads >= 1) {
|
||||
StartScriptCheckWorkerThreads(script_threads);
|
||||
}
|
||||
|
||||
assert(!node.scheduler);
|
||||
node.scheduler = std::make_unique<CScheduler>();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user