Merge branch '0.5.0.x' into 0.5.x

This commit is contained in:
Luke Dashjr 2012-02-17 09:40:00 -05:00
commit 6fb186f4bb
3 changed files with 23 additions and 19 deletions

View File

@ -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;
}

View File

@ -284,7 +284,7 @@ public:
void BeginMessage(const char* pszCommand)
{
cs_vSend.Enter("cs_vSend", __FILE__, __LINE__);
ENTER_CRITICAL_SECTION(cs_vSend);
if (nHeaderStart != -1)
AbortMessage();
nHeaderStart = vSend.size();
@ -303,7 +303,7 @@ public:
vSend.resize(nHeaderStart);
nHeaderStart = -1;
nMessageStart = -1;
cs_vSend.Leave();
LEAVE_CRITICAL_SECTION(cs_vSend);
if (fDebug)
printf("(aborted)\n");
@ -341,7 +341,7 @@ public:
nHeaderStart = -1;
nMessageStart = -1;
cs_vSend.Leave();
LEAVE_CRITICAL_SECTION(cs_vSend);
}
void EndMessageAbortIfEmpty()

View File

@ -258,6 +258,12 @@ public:
#define CRITICAL_BLOCK(cs) \
if (CCriticalBlock criticalblock = CCriticalBlock(cs, #cs, __FILE__, __LINE__))
#define ENTER_CRITICAL_SECTION(cs) \
(cs).Enter(#cs, __FILE__, __LINE__)
#define LEAVE_CRITICAL_SECTION(cs) \
(cs).Leave()
class CTryCriticalBlock
{
protected: