From: R E Broadley Date: Wed, 18 Apr 2012 11:30:24 +0000 (+0100) Subject: Added ability to respond to signals during Block Loading stage. X-Git-Tag: v0.4.0-unstable~129^2~56^2 X-Git-Url: https://git.novaco.in/?p=novacoin.git;a=commitdiff_plain;h=871c3557bf08dd29c6d2ffd10e854bbd0478b3b5 Added ability to respond to signals during Block Loading stage. --- diff --git a/src/db.cpp b/src/db.cpp index c38070f..39a4189 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 > vSortedByHeight; vSortedByHeight.reserve(mapBlockIndex.size()); diff --git a/src/init.cpp b/src/init.cpp index 0eb37fe..14db9e7 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..."));