aboutsummaryrefslogtreecommitdiff
path: root/src/shutdown.cpp
diff options
context:
space:
mode:
authorBen Woosley <ben.woosley@gmail.com>2018-05-16 19:17:40 +0000
committerBen Woosley <ben.woosley@gmail.com>2018-06-25 00:08:49 -0400
commit1fabd59e7e870fae73bfbcfb227dd7452de94726 (patch)
treec6b4ec2a9f4e6e2897633cccdd82d13cc10acbe2 /src/shutdown.cpp
parente62fdfeeab13ff65bcedac30f08a3216f3b29255 (diff)
downloadbitcoin-1fabd59e7e870fae73bfbcfb227dd7452de94726.tar.xz
Break circular dependency: init -> * -> init by extracting shutdown.h
Most includers just wanted to react to pending shutdown. This isolates access to `fRequestShutdown` and limits access to the shutdown api functions, including the new `AbortShutdown` for setting it to `false`. Note I originally called `AbortShutdown` `CancelShutdown` but that name was already taken by winuser.h https://travis-ci.org/bitcoin/bitcoin/jobs/386913329 This change also triggered a build error in bench. Fixing it required moving LIBBITCOIN_SERVER after LIBBITCOIN_WALLET in bench_bench_bitcoin_LDADD To make server definitions in src/net.cpp available to wallet methods in src/wallet/wallet.cpp. Specifically, solving: libbitcoin_wallet.a(libbitcoin_wallet_a-wallet.o): In function `CWalletTx::RelayWalletTransaction(CConnman*)': wallet.cpp:(.text+0x3f0e): undefined reference to `CConnman::NodeFullyConnected(CNode const*)' collect2: error: ld returned 1 exit status https://travis-ci.org/bitcoin/bitcoin/jobs/392133581 Need for remaining init.h includes confirmed via a thorough search with a more specific regex: \bInterrupt\(\)|\bShutdown\(\)|\bInitLogging\(\)|\bInitParameterInteraction\(\)|\bAppInitBasicSetup\(\)|\bAppInitParameterInteraction\(\)|\bAppInitSanityChecks\(\)|\bAppInitLockDataDirectory\(\)|\bAppInitMain\(\)|\bSetupServerArgs\(\)|\bLicenseInfo\(\)|g_wallet_init_interface|init.h
Diffstat (limited to 'src/shutdown.cpp')
-rw-r--r--src/shutdown.cpp23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/shutdown.cpp b/src/shutdown.cpp
new file mode 100644
index 0000000000..dec497d8ec
--- /dev/null
+++ b/src/shutdown.cpp
@@ -0,0 +1,23 @@
+// Copyright (c) 2009-2010 Satoshi Nakamoto
+// Copyright (c) 2009-2018 The Bitcoin Core developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#include <shutdown.h>
+
+#include <atomic>
+
+static std::atomic<bool> fRequestShutdown(false);
+
+void StartShutdown()
+{
+ fRequestShutdown = true;
+}
+void AbortShutdown()
+{
+ fRequestShutdown = false;
+}
+bool ShutdownRequested()
+{
+ return fRequestShutdown;
+}