aboutsummaryrefslogtreecommitdiff
path: root/src/bitcoinrpc.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2012-02-11 16:35:40 +0100
committerPieter Wuille <pieter.wuille@gmail.com>2012-02-11 21:59:39 +0100
commitb0529ffd951fdaa7ecc823381a6a7b0c88b5b2b0 (patch)
tree1b57faafefae397a8c35ce816cba186f06832f03 /src/bitcoinrpc.cpp
parent88bc5f94852a0b2839a3ef4e1a6a5168d02f6b55 (diff)
Fix wallet locking locking
Diffstat (limited to 'src/bitcoinrpc.cpp')
-rw-r--r--src/bitcoinrpc.cpp30
1 files changed, 14 insertions, 16 deletions
diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp
index 5d38f042f9..8f98135617 100644
--- a/src/bitcoinrpc.cpp
+++ b/src/bitcoinrpc.cpp
@@ -1539,33 +1539,31 @@ void ThreadCleanWalletPassphrase(void* parg)
{
int64 nMyWakeTime = GetTime() + *((int*)parg);
+ ENTER_CRITICAL_SECTION(cs_nWalletUnlockTime);
+
if (nWalletUnlockTime == 0)
{
- CRITICAL_BLOCK(cs_nWalletUnlockTime)
- {
- nWalletUnlockTime = nMyWakeTime;
- }
+ nWalletUnlockTime = nMyWakeTime;
while (GetTime() < nWalletUnlockTime)
- Sleep(GetTime() - nWalletUnlockTime);
-
- CRITICAL_BLOCK(cs_nWalletUnlockTime)
{
- nWalletUnlockTime = 0;
+ int64 nToSleep = GetTime() - nWalletUnlockTime;
+
+ LEAVE_CRITICAL_SECTION(cs_nWalletUnlockTime);
+ Sleep(nToSleep);
+ ENTER_CRITICAL_SECTION(cs_nWalletUnlockTime);
}
+
+ nWalletUnlockTime = 0;
+ pwalletMain->Lock();
}
else
{
- CRITICAL_BLOCK(cs_nWalletUnlockTime)
- {
- if (nWalletUnlockTime < nMyWakeTime)
- nWalletUnlockTime = nMyWakeTime;
- }
- delete (int*)parg;
- return;
+ if (nWalletUnlockTime < nMyWakeTime)
+ nWalletUnlockTime = nMyWakeTime;
}
- pwalletMain->Lock();
+ LEAVE_CRITICAL_SECTION(cs_nWalletUnlockTime);
delete (int*)parg;
}