Skip to content

Commit ae09d45

Browse files
committed
Allow to shut down during txdb upgrade
1 parent 00cb69b commit ae09d45

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/init.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1358,7 +1358,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
13581358
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));
13591359

13601360
bool fLoaded = false;
1361-
while (!fLoaded) {
1361+
while (!fLoaded && !fRequestShutdown) {
13621362
bool fReset = fReindex;
13631363
std::string strLoadError;
13641364

@@ -1389,6 +1389,7 @@ bool AppInitMain(boost::thread_group& threadGroup, CScheduler& scheduler)
13891389
break;
13901390
}
13911391
}
1392+
if (fRequestShutdown) break;
13921393

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

1469-
if (!fLoaded) {
1470+
if (!fLoaded && !fRequestShutdown) {
14701471
// first suggest a reindex
14711472
if (!fReset) {
14721473
bool fRet = uiInterface.ThreadSafeQuestion(

src/txdb.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,9 @@ bool CCoinsViewDB::Upgrade() {
371371
CDBBatch batch(db);
372372
while (pcursor->Valid()) {
373373
boost::this_thread::interruption_point();
374+
if (ShutdownRequested()) {
375+
break;
376+
}
374377
std::pair<unsigned char, uint256> key;
375378
if (pcursor->GetKey(key) && key.first == DB_COINS) {
376379
CCoins old_coins;

0 commit comments

Comments
 (0)