From 4783aa04109ce4476dbb07291d6c8e203ef583f8 Mon Sep 17 00:00:00 2001 From: Prasanna Loganathar Date: Tue, 2 Aug 2022 14:00:02 +0530 Subject: [PATCH] Make shutdown handling safer (#1404) * Make shutdown behavior safer Co-authored-by: Peter Bushnell --- src/init.cpp | 4 ++++ src/masternodes/anchors.h | 2 -- src/spv/spv_wrapper.h | 6 +----- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index cd568b4f05..c835f3bc7d 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -795,6 +795,10 @@ static void ThreadImport(std::vector vImportFiles) if (file) { LogPrintf("Importing blocks file %s...\n", path.string()); LoadExternalBlockFile(chainparams, file); + if (ShutdownRequested()) { + LogPrintf("Shutdown requested. Exit %s\n", __func__); + return; + } } else { LogPrintf("Warning: Could not open blocks file %s\n", path.string()); } diff --git a/src/masternodes/anchors.h b/src/masternodes/anchors.h index d0d1322249..c7659be26b 100644 --- a/src/masternodes/anchors.h +++ b/src/masternodes/anchors.h @@ -276,8 +276,6 @@ class CAnchorIndex while (pcursor->Valid()) { - // ShutdownRequested replaces interruption_point - if (ShutdownRequested()) break; std::pair key; if (pcursor->GetKey(key) && key.first == prefix) { diff --git a/src/spv/spv_wrapper.h b/src/spv/spv_wrapper.h index e704f7da65..b6fdcb2437 100644 --- a/src/spv/spv_wrapper.h +++ b/src/spv/spv_wrapper.h @@ -197,8 +197,6 @@ class CSpvWrapper while (pcursor->Valid()) { - // ShutdownRequested replaces interruption_point - if (ShutdownRequested()) break; std::pair key; if (pcursor->GetKey(key) && key.first == prefix) { @@ -226,8 +224,6 @@ class CSpvWrapper while (pcursor->Valid()) { - // ShutdownRequested replaces interruption_point - if (ShutdownRequested()) break; std::pair key; if (pcursor->GetKey(key) && key.first == prefix) { @@ -256,7 +252,7 @@ class CFakeSpvWrapper : public CSpvWrapper CFakeSpvWrapper(); void Connect() override; - void Disconnect() override; + void Disconnect() override; bool IsConnected() const override; void CancelPendingTxs() override;