-
Notifications
You must be signed in to change notification settings - Fork 37.8k
Break circular dependency: init -> * -> init by extracting shutdown.h #13235
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Prompted by #13228 |
Failures in bench_bitcoin in a few of the Travis builds:
|
Concept ACK |
I entertained the idea of creating a |
58bc7bf
to
624d44a
Compare
Based this on #13239, which fixes the linker issues. |
a5710f1
to
f7033bf
Compare
utACK f7033bf5767e674abfee2bd53cd6b9f5c3831482 |
1 similar comment
utACK f7033bf5767e674abfee2bd53cd6b9f5c3831482 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Concept ACK.
The PR suggests that the following dependencies wouldn't exist:
Circular dependency: init -> net_processing -> init
Circular dependency: init -> validationinterface -> init
Also, I've removed the first 3 commits locally and it still compiles and reports the same dependencies as above. I wonder why are those commits included here.
Edit: oh this is rebased on #13239.
src/shutdown.cpp
Outdated
|
||
#include <atomic> | ||
|
||
std::atomic<bool> fRequestShutdown(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
static std::atomic<bool> fRequestShutdown{false};
src/shutdown.h
Outdated
@@ -0,0 +1,13 @@ | |||
// Copyright (c) 2009-2010 Satoshi Nakamoto | |||
// Copyright (c) 2009-2017 The Bitcoin Core developers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/txdb.cpp
Outdated
@@ -12,7 +12,7 @@ | |||
#include <uint256.h> | |||
#include <util.h> | |||
#include <ui_interface.h> | |||
#include <init.h> | |||
#include <shutdown.h> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keep sorted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that you can install clang-format
and run the https://github.com/bitcoin/bitcoin/tree/master/contrib/devtools#clang-format-diffpy script which fixes all white space and sorting issues
src/shutdown.cpp
Outdated
// Distributed under the MIT software license, see the accompanying | ||
// file COPYING or http://www.opensource.org/licenses/mit-license.php. | ||
|
||
#include <atomic> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit, also #include <shutdown.h>
?
4f4cae6
to
e52d0bf
Compare
Thanks @promag / @MarcoFalke |
Still has the following circular dependencies:
Should these be removed in this PR? |
@promag Added a commit to remove unused includes of init from 4 files. I'd looked into those before but left them out to narrow this PR. |
@Empact needs rebase. |
Rebased |
|
5ab1f4c
to
2e73ca5
Compare
a4e0fdf
to
9b583bd
Compare
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
Rebased for #13458 |
utACK 1fabd59 |
@Empact In your first commit you write "These were entirely unused, as based on successful compilation". That's not a sufficient argument - init.h could still be included indirectly through another header, while exported symbols from init.h are still used. This doesn't mean it wrong to remove them, just that "it compiles without them" isn't a sufficient reason. Tools like |
@sipa thanks I’ll check that out |
Oh btw I did manually check using this grep:
But I'll check again with the above and using |
@Empact Oh, ignore my comment in that case. I just wanted to make sure you're not relying on indirect inclusions. |
utACK 1fabd59 |
@practicalswift @jonasschnelli @promag could I get another look? Alternatively I could split this into 2 PRS, the removal of the unnecessary includes and the shutdown.h extraction, if that would make review easier. |
utACK 1fabd59 |
…ing shutdown.h 1fabd59 Break circular dependency: init -> * -> init by extracting shutdown.h (Ben Woosley) e62fdfe Drop unused init.h includes (Ben Woosley) Pull request description: 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 `CancelShutdown` for setting it to `false`. Tree-SHA512: df42f75dfbba163576710e9a67cf1228531fd99d70a2f187bfba0bcc476d6749cf88180a97e66a81bb5b6c3c7f0917de7402d26039ba7b644cb7509b02f7e267
…extracting shutdown.h 1fabd59 Break circular dependency: init -> * -> init by extracting shutdown.h (Ben Woosley) e62fdfe Drop unused init.h includes (Ben Woosley) Pull request description: 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 `CancelShutdown` for setting it to `false`. Tree-SHA512: df42f75dfbba163576710e9a67cf1228531fd99d70a2f187bfba0bcc476d6749cf88180a97e66a81bb5b6c3c7f0917de7402d26039ba7b644cb7509b02f7e267
…extracting shutdown.h 1fabd59 Break circular dependency: init -> * -> init by extracting shutdown.h (Ben Woosley) e62fdfe Drop unused init.h includes (Ben Woosley) Pull request description: 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 `CancelShutdown` for setting it to `false`. Tree-SHA512: df42f75dfbba163576710e9a67cf1228531fd99d70a2f187bfba0bcc476d6749cf88180a97e66a81bb5b6c3c7f0917de7402d26039ba7b644cb7509b02f7e267
…extracting shutdown.h 1fabd59 Break circular dependency: init -> * -> init by extracting shutdown.h (Ben Woosley) e62fdfe Drop unused init.h includes (Ben Woosley) Pull request description: 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 `CancelShutdown` for setting it to `false`. Tree-SHA512: df42f75dfbba163576710e9a67cf1228531fd99d70a2f187bfba0bcc476d6749cf88180a97e66a81bb5b6c3c7f0917de7402d26039ba7b644cb7509b02f7e267
…extracting shutdown.h 1fabd59 Break circular dependency: init -> * -> init by extracting shutdown.h (Ben Woosley) e62fdfe Drop unused init.h includes (Ben Woosley) Pull request description: 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 `CancelShutdown` for setting it to `false`. Tree-SHA512: df42f75dfbba163576710e9a67cf1228531fd99d70a2f187bfba0bcc476d6749cf88180a97e66a81bb5b6c3c7f0917de7402d26039ba7b644cb7509b02f7e267
…extracting shutdown.h 1fabd59 Break circular dependency: init -> * -> init by extracting shutdown.h (Ben Woosley) e62fdfe Drop unused init.h includes (Ben Woosley) Pull request description: 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 `CancelShutdown` for setting it to `false`. Tree-SHA512: df42f75dfbba163576710e9a67cf1228531fd99d70a2f187bfba0bcc476d6749cf88180a97e66a81bb5b6c3c7f0917de7402d26039ba7b644cb7509b02f7e267
…extracting shutdown.h 1fabd59 Break circular dependency: init -> * -> init by extracting shutdown.h (Ben Woosley) e62fdfe Drop unused init.h includes (Ben Woosley) Pull request description: 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 `CancelShutdown` for setting it to `false`. Tree-SHA512: df42f75dfbba163576710e9a67cf1228531fd99d70a2f187bfba0bcc476d6749cf88180a97e66a81bb5b6c3c7f0917de7402d26039ba7b644cb7509b02f7e267
…extracting shutdown.h 1fabd59 Break circular dependency: init -> * -> init by extracting shutdown.h (Ben Woosley) e62fdfe Drop unused init.h includes (Ben Woosley) Pull request description: 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 `CancelShutdown` for setting it to `false`. Tree-SHA512: df42f75dfbba163576710e9a67cf1228531fd99d70a2f187bfba0bcc476d6749cf88180a97e66a81bb5b6c3c7f0917de7402d26039ba7b644cb7509b02f7e267
…extracting shutdown.h 1fabd59 Break circular dependency: init -> * -> init by extracting shutdown.h (Ben Woosley) e62fdfe Drop unused init.h includes (Ben Woosley) Pull request description: 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 `CancelShutdown` for setting it to `false`. Tree-SHA512: df42f75dfbba163576710e9a67cf1228531fd99d70a2f187bfba0bcc476d6749cf88180a97e66a81bb5b6c3c7f0917de7402d26039ba7b644cb7509b02f7e267
…extracting shutdown.h 1fabd59 Break circular dependency: init -> * -> init by extracting shutdown.h (Ben Woosley) e62fdfe Drop unused init.h includes (Ben Woosley) Pull request description: 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 `CancelShutdown` for setting it to `false`. Tree-SHA512: df42f75dfbba163576710e9a67cf1228531fd99d70a2f187bfba0bcc476d6749cf88180a97e66a81bb5b6c3c7f0917de7402d26039ba7b644cb7509b02f7e267
…extracting shutdown.h 1fabd59 Break circular dependency: init -> * -> init by extracting shutdown.h (Ben Woosley) e62fdfe Drop unused init.h includes (Ben Woosley) Pull request description: 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 `CancelShutdown` for setting it to `false`. Tree-SHA512: df42f75dfbba163576710e9a67cf1228531fd99d70a2f187bfba0bcc476d6749cf88180a97e66a81bb5b6c3c7f0917de7402d26039ba7b644cb7509b02f7e267
Most includers just wanted to react to pending shutdown.
This isolates access to
fRequestShutdown
and limits access to the shutdown api functions, including the newCancelShutdown
for setting it tofalse
.