mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-23 13:29:43 +02:00
Return EXIT_FAILURE on post-init fatal errors
It seems odd to return `EXIT_SUCCESS` when the node aborted execution due a fatal internal error or any post-init problem that triggers an unrequested shutdown. e.g. blocks or coins db I/O errors, disconnect block failure, failure during thread import (external blocks loading process error), among others. Co-authored-by: Ryan Ofsky <ryan@ofsky.org>
This commit is contained in:
@@ -7,7 +7,9 @@
|
||||
|
||||
#include <kernel/context.h>
|
||||
|
||||
#include <atomic>
|
||||
#include <cassert>
|
||||
#include <cstdlib>
|
||||
#include <functional>
|
||||
#include <memory>
|
||||
#include <vector>
|
||||
@@ -65,6 +67,7 @@ struct NodeContext {
|
||||
std::unique_ptr<CScheduler> scheduler;
|
||||
std::function<void()> rpc_interruption_point = [] {};
|
||||
std::unique_ptr<KernelNotifications> notifications;
|
||||
std::atomic<int> exit_status{EXIT_SUCCESS};
|
||||
|
||||
//! Declare default constructor and destructor that are not inline, so code
|
||||
//! instantiating the NodeContext struct doesn't need to #include class
|
||||
|
||||
@@ -92,7 +92,7 @@ public:
|
||||
uint32_t getLogCategories() override { return LogInstance().GetCategoryMask(); }
|
||||
bool baseInitialize() override
|
||||
{
|
||||
if (!AppInitBasicSetup(args())) return false;
|
||||
if (!AppInitBasicSetup(args(), Assert(context())->exit_status)) return false;
|
||||
if (!AppInitParameterInteraction(args(), /*use_syscall_sandbox=*/false)) return false;
|
||||
|
||||
m_context->kernel = std::make_unique<kernel::Context>();
|
||||
|
||||
Reference in New Issue
Block a user