mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-24 22:45:41 +01:00
Merge #20605: init: Signal-safe instant shutdown
cd03513dc2init: Signal-safe instant shutdown (Wladimir J. van der Laan) Pull request description: Replace the 200ms polling loop with a faster and more efficient waiting operation. This should speed up short RPC tests. This change has been tried a few times before, but abandoned every time because solutions used a condition variable which is not safe for use in signals, as they need to be reentrant. On UNIX-ish OSes, use a safe way: a pipe. When shutdown is requested write a dummy byte to the pipe. Waiting for shutdown is a matter of a blocking read from the pipe. On Windows, there are no signals so using a condition variable is safe. This only affects bitcoind. The GUI is unaffected by this change, and keeps polling as before in `BitcoinGUI::detectShutdown()`. It might be possible to listen to a pipe there, too, but I'm not sure, and it's complicated by the GUI-node abstraction. ACKs for top commit: jonatack: ACKcd03513dc2tested on Debian 5.9.11-1 (2020-11-27) x86_64 GNU/Linux Tree-SHA512: ed2f532f69fec4855c17bf7b8f3d0eb96e78ee2a3c13d374dd2c6add06e3ad6a190da8ed8f9d7a76532cf998222d67f57e35b206aec29675e96437448ae7e13c
This commit is contained in:
@@ -917,6 +917,9 @@ bool AppInitBasicSetup(const ArgsManager& args)
|
||||
// Enable heap terminate-on-corruption
|
||||
HeapSetInformation(nullptr, HeapEnableTerminationOnCorruption, nullptr, 0);
|
||||
#endif
|
||||
if (!InitShutdownState()) {
|
||||
return InitError(Untranslated("Initializing wait-for-shutdown state failed."));
|
||||
}
|
||||
|
||||
if (!SetupNetworking()) {
|
||||
return InitError(Untranslated("Initializing networking failed."));
|
||||
|
||||
Reference in New Issue
Block a user