Skip to content

Commit 9479f8d

Browse files
committed
Allow shutdown during LoadMempool, dump only when necessary
1 parent 041331e commit 9479f8d

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
@@ -130,6 +130,7 @@ static const char* FEE_ESTIMATES_FILENAME="fee_estimates.dat";
130130
//
131131

132132
std::atomic<bool> fRequestShutdown(false);
133+
std::atomic<bool> fDumpMempoolLater(false);
133134

134135
void StartShutdown()
135136
{
@@ -209,7 +210,8 @@ void Shutdown()
209210

210211
StopTorControl();
211212
UnregisterNodeSignals(GetNodeSignals());
212-
DumpMempool();
213+
if (fDumpMempoolLater)
214+
DumpMempool();
213215

214216
if (fFeeEstimatesInitialized)
215217
{
@@ -667,6 +669,7 @@ void ThreadImport(std::vector<boost::filesystem::path> vImportFiles)
667669
}
668670
} // End scope of CImportingNow
669671
LoadMempool();
672+
fDumpMempoolLater = !fRequestShutdown;
670673
}
671674

672675
/** Sanity checks

src/validation.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4076,6 +4076,8 @@ bool LoadMempool(void)
40764076
} else {
40774077
++skipped;
40784078
}
4079+
if (ShutdownRequested())
4080+
return false;
40794081
}
40804082
std::map<uint256, CAmount> mapDeltas;
40814083
file >> mapDeltas;

0 commit comments

Comments
 (0)