aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLuke Dashjr <luke-jr+git@utopios.org>2012-02-17 09:39:54 -0500
committerLuke Dashjr <luke-jr+git@utopios.org>2012-02-17 09:39:54 -0500
commitfdb365df0e9bf1b3073ea38212664cb59863bbd0 (patch)
tree8295f7921c90f40e561d1931eba0e4377d5055ea
parent0365f19dececa3bd84ae28ec4aabb955ffb8b405 (diff)
parent8960f2fc3353d5d7f8b9babd1aaef0e9869e39f4 (diff)
downloadbitcoin-fdb365df0e9bf1b3073ea38212664cb59863bbd0.tar.xz
Merge branch '0.4.x' into 0.5.0.x
-rw-r--r--src/bitcoinrpc.cpp30
-rw-r--r--src/net.h6
-rw-r--r--src/util.h6
3 files changed, 23 insertions, 19 deletions
diff --git a/src/bitcoinrpc.cpp b/src/bitcoinrpc.cpp
index cf03666582..a09d7c7a49 100644
--- a/src/bitcoinrpc.cpp
+++ b/src/bitcoinrpc.cpp
@@ -1405,33 +1405,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;
}
diff --git a/src/net.h b/src/net.h
index 4eadeaa8aa..55f4d743dc 100644
--- a/src/net.h
+++ b/src/net.h
@@ -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()
diff --git a/src/util.h b/src/util.h
index e78fd134cf..19a291209a 100644
--- a/src/util.h
+++ b/src/util.h
@@ -257,6 +257,12 @@ public:
for (bool fcriticalblockonce=true; fcriticalblockonce; assert(("break caught by CRITICAL_BLOCK!" && !fcriticalblockonce)), fcriticalblockonce=false) \
for (CCriticalBlock criticalblock(cs, #cs, __FILE__, __LINE__); fcriticalblockonce; fcriticalblockonce=false)
+#define ENTER_CRITICAL_SECTION(cs) \
+ (cs).Enter(#cs, __FILE__, __LINE__)
+
+#define LEAVE_CRITICAL_SECTION(cs) \
+ (cs).Leave()
+
class CTryCriticalBlock
{
protected: