aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2012-02-11 20:02:55 +0100
committerLuke Dashjr <luke-jr+git@utopios.org>2012-02-17 09:38:13 -0500
commit43163a5a4d0fd3c849dbb2e7070b7ba4f7a70d27 (patch)
treeb77f074d668c1bb8c52012890532e5b57ea49e8d
parentd52397b3c02330d17cde6952e8bbc1c492c06007 (diff)
downloadbitcoin-43163a5a4d0fd3c849dbb2e7070b7ba4f7a70d27.tar.xz
Macros for manual critical sections
-rw-r--r--src/net.h6
-rw-r--r--src/util.h6
2 files changed, 9 insertions, 3 deletions
diff --git a/src/net.h b/src/net.h
index d8b9022276..53e13fd095 100644
--- a/src/net.h
+++ b/src/net.h
@@ -277,7 +277,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();
@@ -296,7 +296,7 @@ public:
vSend.resize(nHeaderStart);
nHeaderStart = -1;
nMessageStart = -1;
- cs_vSend.Leave();
+ LEAVE_CRITICAL_SECTION(cs_vSend);
if (fDebug)
printf("(aborted)\n");
@@ -334,7 +334,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 a48979c0ef..c4ee19fe01 100644
--- a/src/util.h
+++ b/src/util.h
@@ -254,6 +254,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: