From 52ecb6547dd2b59643483e43531d1201941c0df0 Mon Sep 17 00:00:00 2001 From: Ryan Ofsky Date: Fri, 7 Jul 2023 17:32:54 -0400 Subject: [PATCH] Get rid of shutdown.cpp/shutdown.h, use SignalInterrupt directly This change is mostly a refectoring that removes some code and gets rid of an unnecessary layer of indirection after #27861 But it is not a pure refactoring since StartShutdown, AbortShutdown, and WaitForShutdown functions used to abort on failure, and the replacement code logs or returns errors instead. --- src/Makefile.am | 2 -- src/bitcoind.cpp | 6 +--- src/init.cpp | 55 +++++++++++++++++++++++----------- src/init.h | 4 ++- src/kernel/context.cpp | 6 ---- src/kernel/context.h | 15 ---------- src/node/interfaces.cpp | 11 +++---- src/shutdown.cpp | 43 -------------------------- src/shutdown.h | 25 ---------------- src/test/util/setup_common.cpp | 1 - 10 files changed, 47 insertions(+), 121 deletions(-) delete mode 100644 src/shutdown.cpp delete mode 100644 src/shutdown.h diff --git a/src/Makefile.am b/src/Makefile.am index 8905c0ad1cd25..e54823600a732 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -270,7 +270,6 @@ BITCOIN_CORE_H = \ script/sign.h \ script/signingprovider.h \ script/solver.h \ - shutdown.h \ signet.h \ streams.h \ support/allocators/pool.h \ @@ -456,7 +455,6 @@ libbitcoin_node_a_SOURCES = \ rpc/signmessage.cpp \ rpc/txoutproof.cpp \ script/sigcache.cpp \ - shutdown.cpp \ signet.cpp \ timedata.cpp \ torcontrol.cpp \ diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index ccdc628a0fd36..4f0a816388e7f 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -185,7 +184,6 @@ static bool AppInit(NodeContext& node) } node.kernel = std::make_unique(); - node.shutdown = &node.kernel->interrupt; // TEMPORARY: will go away when kernel->interrupt member is removed if (!AppInitSanityChecks(*node.kernel)) { // InitError will have been called with detailed error, which ends up on console @@ -273,9 +271,7 @@ MAIN_FUNCTION if (ProcessInitCommands(args)) return EXIT_SUCCESS; // Start application - if (AppInit(node)) { - WaitForShutdown(); - } else { + if (!AppInit(node) || !Assert(node.shutdown)->wait()) { node.exit_status = EXIT_FAILURE; } Interrupt(node); diff --git a/src/init.cpp b/src/init.cpp index 8e8439aaae3f3..3f5ce3eba7737 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -66,7 +66,6 @@ #include #include #include