diff options
author | Pieter Wuille <pieter.wuille@gmail.com> | 2012-04-19 04:33:04 -0700 |
---|---|---|
committer | Pieter Wuille <pieter.wuille@gmail.com> | 2012-04-19 04:33:04 -0700 |
commit | 3b9e6b7820bf2fa98c8c2ae296cbe5fb043f690f (patch) | |
tree | 2bcec5de60e32c895946a1cda2b4440ff8313f86 | |
parent | ac4161e25df2a9475abb0f62d32a7d86d6baff0f (diff) | |
parent | 871c3557bf08dd29c6d2ffd10e854bbd0478b3b5 (diff) |
Merge pull request #959 from rebroad/LoadBlockIndexKillable
Added ability to respond to signals during Block Loading stage.
-rw-r--r-- | src/db.cpp | 7 | ||||
-rw-r--r-- | src/init.cpp | 9 |
2 files changed, 14 insertions, 2 deletions
diff --git a/src/db.cpp b/src/db.cpp index c38070f347..39a41894d7 100644 --- a/src/db.cpp +++ b/src/db.cpp @@ -529,7 +529,7 @@ bool CTxDB::LoadBlockIndex() // Unserialize string strType; ssKey >> strType; - if (strType == "blockindex") + if (strType == "blockindex" && !fRequestShutdown) { CDiskBlockIndex diskindex; ssValue >> diskindex; @@ -556,11 +556,14 @@ bool CTxDB::LoadBlockIndex() } else { - break; + break; // if shutdown requested or finished loading block index } } pcursor->close(); + if (fRequestShutdown) + return true; + // Calculate bnChainWork vector<pair<int, CBlockIndex*> > vSortedByHeight; vSortedByHeight.reserve(mapBlockIndex.size()); diff --git a/src/init.cpp b/src/init.cpp index 0eb37fe99c..14db9e7f5e 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -353,6 +353,15 @@ bool AppInit2(int argc, char* argv[]) nStart = GetTimeMillis(); if (!LoadBlockIndex()) strErrors << _("Error loading blkindex.dat") << "\n"; + + // as LoadBlockIndex can take several minutes, it's possible the user + // requested to kill bitcoin-qt during the last operation. If so, exit. + // As the program has not fully started yet, Shutdown() is possibly overkill. + if (fRequestShutdown) + { + printf("Shutdown requested. Exiting.\n"); + return false; + } printf(" block index %15"PRI64d"ms\n", GetTimeMillis() - nStart); InitMessage(_("Loading wallet...")); |