Changeset View
Changeset View
Standalone View
Standalone View
src/init.cpp
Show First 20 Lines • Show All 124 Lines • ▼ Show 20 Lines | |||||
// adding any threads to the threadGroup, so .join_all() returns immediately and | // adding any threads to the threadGroup, so .join_all() returns immediately and | ||||
// the parent exits from main(). | // the parent exits from main(). | ||||
// | // | ||||
// Shutdown for Qt is very similar, only it uses a QTimer to detect | // Shutdown for Qt is very similar, only it uses a QTimer to detect | ||||
// fRequestShutdown getting set, and then does the normal Qt shutdown thing. | // fRequestShutdown getting set, and then does the normal Qt shutdown thing. | ||||
// | // | ||||
std::atomic<bool> fRequestShutdown(false); | std::atomic<bool> fRequestShutdown(false); | ||||
std::atomic<bool> fDumpMempoolLater(false); | |||||
void StartShutdown() { | void StartShutdown() { | ||||
fRequestShutdown = true; | fRequestShutdown = true; | ||||
} | } | ||||
bool ShutdownRequested() { | bool ShutdownRequested() { | ||||
return fRequestShutdown; | return fRequestShutdown; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 79 Lines • ▼ Show 20 Lines | void Shutdown() { | ||||
StopTorControl(); | StopTorControl(); | ||||
// After everything has been shut down, but before things get flushed, stop | // After everything has been shut down, but before things get flushed, stop | ||||
// the CScheduler/checkqueue threadGroup | // the CScheduler/checkqueue threadGroup | ||||
threadGroup.interrupt_all(); | threadGroup.interrupt_all(); | ||||
threadGroup.join_all(); | threadGroup.join_all(); | ||||
if (fDumpMempoolLater && | if (g_is_mempool_loaded && | ||||
gArgs.GetArg("-persistmempool", DEFAULT_PERSIST_MEMPOOL)) { | gArgs.GetArg("-persistmempool", DEFAULT_PERSIST_MEMPOOL)) { | ||||
DumpMempool(); | DumpMempool(); | ||||
} | } | ||||
// FlushStateToDisk generates a SetBestChain callback, which we should avoid | // FlushStateToDisk generates a SetBestChain callback, which we should avoid | ||||
// missing | // missing | ||||
if (pcoinsTip != nullptr) { | if (pcoinsTip != nullptr) { | ||||
FlushStateToDisk(); | FlushStateToDisk(); | ||||
▲ Show 20 Lines • Show All 868 Lines • ▼ Show 20 Lines | RenameThread("bitcoin-loadblk"); | ||||
if (gArgs.GetBoolArg("-stopafterblockimport", | if (gArgs.GetBoolArg("-stopafterblockimport", | ||||
DEFAULT_STOPAFTERBLOCKIMPORT)) { | DEFAULT_STOPAFTERBLOCKIMPORT)) { | ||||
LogPrintf("Stopping after block import\n"); | LogPrintf("Stopping after block import\n"); | ||||
StartShutdown(); | StartShutdown(); | ||||
} | } | ||||
} // End scope of CImportingNow | } // End scope of CImportingNow | ||||
if (gArgs.GetArg("-persistmempool", DEFAULT_PERSIST_MEMPOOL)) { | if (gArgs.GetArg("-persistmempool", DEFAULT_PERSIST_MEMPOOL)) { | ||||
LoadMempool(config); | LoadMempool(config); | ||||
fDumpMempoolLater = !fRequestShutdown; | |||||
} | } | ||||
g_is_mempool_loaded = !fRequestShutdown; | |||||
} | } | ||||
/** Sanity checks | /** Sanity checks | ||||
* Ensure that Bitcoin is running in a usable environment with all | * Ensure that Bitcoin is running in a usable environment with all | ||||
* necessary library support. | * necessary library support. | ||||
*/ | */ | ||||
bool InitSanityCheck(void) { | bool InitSanityCheck(void) { | ||||
if (!ECC_InitSanityCheck()) { | if (!ECC_InitSanityCheck()) { | ||||
▲ Show 20 Lines • Show All 1,259 Lines • Show Last 20 Lines |