aboutsummaryrefslogtreecommitdiff
path: root/src/walletdb.cpp
diff options
context:
space:
mode:
authorGavin Andresen <gavinandresen@gmail.com>2013-03-09 12:02:57 -0500
committerGavin Andresen <gavinandresen@gmail.com>2013-04-03 19:57:53 -0400
commitb31499ec72edd1554d4612d1b54808fce0360e14 (patch)
treea2d03852b9fd6e9595470210479f212ccf4313f1 /src/walletdb.cpp
parent21eb5adadbe3110a8708f2570185566e1f137a49 (diff)
Clean up shutdown process
Diffstat (limited to 'src/walletdb.cpp')
-rw-r--r--src/walletdb.cpp16
1 files changed, 9 insertions, 7 deletions
diff --git a/src/walletdb.cpp b/src/walletdb.cpp
index 96bc05b118..abaf5a0fd1 100644
--- a/src/walletdb.cpp
+++ b/src/walletdb.cpp
@@ -451,8 +451,10 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet)
}
pcursor->close();
}
- catch (...)
- {
+ catch (boost::thread_interrupted) {
+ throw;
+ }
+ catch (...) {
result = DB_CORRUPT;
}
@@ -482,12 +484,11 @@ DBErrors CWalletDB::LoadWallet(CWallet* pwallet)
return result;
}
-void ThreadFlushWalletDB(void* parg)
+void ThreadFlushWalletDB(const string& strFile)
{
// Make this thread recognisable as the wallet flushing thread
RenameThread("bitcoin-wallet");
- const string& strFile = ((const string*)parg)[0];
static bool fOneThread;
if (fOneThread)
return;
@@ -498,7 +499,7 @@ void ThreadFlushWalletDB(void* parg)
unsigned int nLastSeen = nWalletDBUpdated;
unsigned int nLastFlushed = nWalletDBUpdated;
int64 nLastWalletUpdate = GetTime();
- while (!fShutdown)
+ while (true)
{
MilliSleep(500);
@@ -522,8 +523,9 @@ void ThreadFlushWalletDB(void* parg)
mi++;
}
- if (nRefCount == 0 && !fShutdown)
+ if (nRefCount == 0)
{
+ boost::this_thread::interruption_point();
map<string, int>::iterator mi = bitdb.mapFileUseCount.find(strFile);
if (mi != bitdb.mapFileUseCount.end())
{
@@ -548,7 +550,7 @@ bool BackupWallet(const CWallet& wallet, const string& strDest)
{
if (!wallet.fFileBacked)
return false;
- while (!fShutdown)
+ while (true)
{
{
LOCK(bitdb.cs_db);