aboutsummaryrefslogtreecommitdiff
path: root/src/bitcoinrpc.cpp
diff options
context:
space:
mode:
authorLuke Dashjr <luke-jr+git@utopios.org>2012-02-17 09:40:00 -0500
committerLuke Dashjr <luke-jr+git@utopios.org>2012-02-17 09:40:00 -0500
commit6fb186f4bbeb34b4e5c22f909e8d0a1a877f1c44 (patch)
treed1d195d7941297367db84da93c259034123c0a88 /src/bitcoinrpc.cpp
parentfb811c31fd28d1d637a50f784af620d085fa32d4 (diff)
parentfdb365df0e9bf1b3073ea38212664cb59863bbd0 (diff)
downloadbitcoin-6fb186f4bbeb34b4e5c22f909e8d0a1a877f1c44.tar.xz
Merge branch '0.5.0.x' into 0.5.x
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 506e194612..57abe8e4f4 100644
--- a/src/bitcoinrpc.cpp
+++ b/src/bitcoinrpc.cpp
@@ -1409,33 +1409,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;
}