Allow to shut down during txdb upgrade

This commit is contained in:
Jonas Schnelli 2017-06-23 09:33:31 +02:00
parent 00cb69bc86
commit ae09d4583b
No known key found for this signature in database
GPG key ID: 1EB776BB03C7922D
2 changed files with 6 additions and 2 deletions

View file

@ -1358,7 +1358,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
LogPrintf("* Using %.1fMiB for in-memory UTXO set (plus up to %.1fMiB of unused mempool space)\n", nCoinCacheUsage * (1.0 / 1024 / 1024), nMempoolSizeMax * (1.0 / 1024 / 1024)); LogPrintf("* Using %.1fMiB for in-memory UTXO set (plus up to %.1fMiB of unused mempool space)\n", nCoinCacheUsage * (1.0 / 1024 / 1024), nMempoolSizeMax * (1.0 / 1024 / 1024));
bool fLoaded = false; bool fLoaded = false;
while (!fLoaded) { while (!fLoaded && !fRequestShutdown) {
bool fReset = fReindex; bool fReset = fReindex;
std::string strLoadError; std::string strLoadError;
@ -1389,6 +1389,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
break; break;
} }
} }
if (fRequestShutdown) break;
if (!LoadBlockIndex(chainparams)) { if (!LoadBlockIndex(chainparams)) {
strLoadError = _("Error loading block database"); strLoadError = _("Error loading block database");
@ -1466,7 +1467,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
fLoaded = true; fLoaded = true;
} while(false); } while(false);
if (!fLoaded) { if (!fLoaded && !fRequestShutdown) {
// first suggest a reindex // first suggest a reindex
if (!fReset) { if (!fReset) {
bool fRet = uiInterface.ThreadSafeQuestion( bool fRet = uiInterface.ThreadSafeQuestion(

View file

@ -371,6 +371,9 @@ bool CCoinsViewDB::Upgrade() {
CDBBatch batch(db); CDBBatch batch(db);
while (pcursor->Valid()) { while (pcursor->Valid()) {
boost::this_thread::interruption_point(); boost::this_thread::interruption_point();
if (ShutdownRequested()) {
break;
}
std::pair<unsigned char, uint256> key; std::pair<unsigned char, uint256> key;
if (pcursor->GetKey(key) && key.first == DB_COINS) { if (pcursor->GetKey(key) && key.first == DB_COINS) {
CCoins old_coins; CCoins old_coins;