diff options
| author | Gavin Andresen <[email protected]> | 2013-04-03 18:25:00 -0700 |
|---|---|---|
| committer | Gavin Andresen <[email protected]> | 2013-04-03 18:25:00 -0700 |
| commit | a0a437c86ae404152de883ac6a1463e6641eda1c (patch) | |
| tree | e99240bd446613584b20c7b9762af5711bf3f7ff /src/walletdb.cpp | |
| parent | Merge pull request #2453 from sipa/txstats (diff) | |
| parent | Have Qt poll for shutdown requested, the QT way. (diff) | |
| download | discoin-a0a437c86ae404152de883ac6a1463e6641eda1c.tar.xz discoin-a0a437c86ae404152de883ac6a1463e6641eda1c.zip | |
Merge pull request #2357 from gavinandresen/shutdowncleanup
Thread / shutdown cleanup
Diffstat (limited to 'src/walletdb.cpp')
| -rw-r--r-- | src/walletdb.cpp | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/walletdb.cpp b/src/walletdb.cpp index fe9bce21e..abaf5a0fd 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,9 +499,9 @@ void ThreadFlushWalletDB(void* parg) unsigned int nLastSeen = nWalletDBUpdated; unsigned int nLastFlushed = nWalletDBUpdated; int64 nLastWalletUpdate = GetTime(); - while (!fShutdown) + while (true) { - Sleep(500); + MilliSleep(500); if (nLastSeen != nWalletDBUpdated) { @@ -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); @@ -579,7 +581,7 @@ bool BackupWallet(const CWallet& wallet, const string& strDest) } } } - Sleep(100); + MilliSleep(100); } return false; } |