Browse Source

Fix wallet locking locking

0.8
Pieter Wuille 13 years ago
parent
commit
b0529ffd95
  1. 24
      src/bitcoinrpc.cpp

24
src/bitcoinrpc.cpp

@ -1539,33 +1539,31 @@ void ThreadCleanWalletPassphrase(void* parg)
{ {
int64 nMyWakeTime = GetTime() + *((int*)parg); int64 nMyWakeTime = GetTime() + *((int*)parg);
ENTER_CRITICAL_SECTION(cs_nWalletUnlockTime);
if (nWalletUnlockTime == 0) if (nWalletUnlockTime == 0)
{
CRITICAL_BLOCK(cs_nWalletUnlockTime)
{ {
nWalletUnlockTime = nMyWakeTime; nWalletUnlockTime = nMyWakeTime;
}
while (GetTime() < nWalletUnlockTime) 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 else
{
CRITICAL_BLOCK(cs_nWalletUnlockTime)
{ {
if (nWalletUnlockTime < nMyWakeTime) if (nWalletUnlockTime < nMyWakeTime)
nWalletUnlockTime = nMyWakeTime; nWalletUnlockTime = nMyWakeTime;
} }
delete (int*)parg;
return;
}
pwalletMain->Lock(); LEAVE_CRITICAL_SECTION(cs_nWalletUnlockTime);
delete (int*)parg; delete (int*)parg;
} }

Loading…
Cancel
Save