Skip to content

Commit e60da98

Browse files
jonasschnellifurszy
authored andcommitted
Allow shutdown during LoadMempool, dump only when necessary
1 parent c0a0e81 commit e60da98

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

src/init.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ CClientUIInterface uiInterface; // Declared but not defined in guiinterface.h
155155
//
156156

157157
volatile bool fRequestShutdown = false;
158+
std::atomic<bool> fDumpMempoolLater(false);
158159

159160
void StartShutdown()
160161
{
@@ -245,7 +246,8 @@ void PrepareShutdown()
245246
DumpBudgets(g_budgetman);
246247
DumpMasternodePayments();
247248
UnregisterNodeSignals(GetNodeSignals());
248-
DumpMempool();
249+
if (fDumpMempoolLater)
250+
DumpMempool();
249251

250252
// After everything has been shut down, but before things get flushed, stop the
251253
// CScheduler/checkqueue threadGroup
@@ -703,6 +705,7 @@ void ThreadImport(std::vector<fs::path> vImportFiles)
703705
}
704706

705707
LoadMempool();
708+
fDumpMempoolLater = !fRequestShutdown;
706709
}
707710

708711
/** Sanity checks

src/validation.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4146,6 +4146,8 @@ bool LoadMempool(void)
41464146
} else {
41474147
++skipped;
41484148
}
4149+
if (ShutdownRequested())
4150+
return false;
41494151
}
41504152
std::map<uint256, CAmount> mapDeltas;
41514153
file >> mapDeltas;

0 commit comments

Comments
 (0)