Skip to content

Commit

Permalink
Allow to shut down during txdb upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
jonasschnelli committed Jun 29, 2017
1 parent 00cb69b commit ae09d45
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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));

bool fLoaded = false;
while (!fLoaded) {
while (!fLoaded && !fRequestShutdown) {
bool fReset = fReindex;
std::string strLoadError;

Expand Down Expand Up @@ -1389,6 +1389,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
break;
}
}
if (fRequestShutdown) break;

if (!LoadBlockIndex(chainparams)) {
strLoadError = _("Error loading block database");
Expand Down Expand Up @@ -1466,7 +1467,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
fLoaded = true;
} while(false);

if (!fLoaded) {
if (!fLoaded && !fRequestShutdown) {
// first suggest a reindex
if (!fReset) {
bool fRet = uiInterface.ThreadSafeQuestion(
Expand Down
3 changes: 3 additions & 0 deletions src/txdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -371,6 +371,9 @@ bool CCoinsViewDB::Upgrade() {
CDBBatch batch(db);
while (pcursor->Valid()) {
boost::this_thread::interruption_point();
if (ShutdownRequested()) {
break;
}
std::pair<unsigned char, uint256> key;
if (pcursor->GetKey(key) && key.first == DB_COINS) {
CCoins old_coins;
Expand Down

0 comments on commit ae09d45

Please sign in to comment.