Skip to content

Commit

Permalink
Allow shutdown during LoadMempool, dump only when necessary
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasschnelli authored and furszy committed Jan 18, 2021
1 parent c0a0e81 commit e60da98
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ CClientUIInterface uiInterface; // Declared but not defined in guiinterface.h
//

volatile bool fRequestShutdown = false;
std::atomic<bool> fDumpMempoolLater(false);

void StartShutdown()
{
Expand Down Expand Up @@ -245,7 +246,8 @@ void PrepareShutdown()
DumpBudgets(g_budgetman);
DumpMasternodePayments();
UnregisterNodeSignals(GetNodeSignals());
DumpMempool();
if (fDumpMempoolLater)
DumpMempool();

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

LoadMempool();
fDumpMempoolLater = !fRequestShutdown;
}

/** Sanity checks
Expand Down
2 changes: 2 additions & 0 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4146,6 +4146,8 @@ bool LoadMempool(void)
} else {
++skipped;
}
if (ShutdownRequested())
return false;
}
std::map<uint256, CAmount> mapDeltas;
file >> mapDeltas;
Expand Down

0 comments on commit e60da98

Please sign in to comment.