aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2012-06-08 07:22:19 -0700
committerPieter Wuille <pieter.wuille@gmail.com>2012-06-08 07:22:19 -0700
commit1b7cd74a495a8fbab9ddcfaea28be25acdfbb200 (patch)
tree58c7310a8033da5846d3096a7382412d371701bf
parentafdd59416ed614c63591946aa95c9334db41fc8c (diff)
parent4d009243cbc2dd5aa172fedbd00c6658ae6ac82d (diff)
Merge pull request #1424 from TheBlueMatt/lockcontention
Fix DEBUG_LOCKCONTENTION
-rw-r--r--src/sync.cpp8
-rw-r--r--src/sync.h7
2 files changed, 13 insertions, 2 deletions
diff --git a/src/sync.cpp b/src/sync.cpp
index f2403a43f2..dbd9ebdaee 100644
--- a/src/sync.cpp
+++ b/src/sync.cpp
@@ -7,6 +7,14 @@
#include <boost/foreach.hpp>
+#ifdef DEBUG_LOCKCONTENTION
+void PrintLockContention(const char* pszName, const char* pszFile, int nLine)
+{
+ printf("LOCKCONTENTION: %s\n", pszName);
+ printf("Locker: %s:%d\n", pszFile, nLine);
+}
+#endif /* DEBUG_LOCKCONTENTION */
+
#ifdef DEBUG_LOCKORDER
//
// Early deadlock detection.
diff --git a/src/sync.h b/src/sync.h
index dffe4f6ee8..98640e6eab 100644
--- a/src/sync.h
+++ b/src/sync.h
@@ -27,6 +27,10 @@ void static inline EnterCritical(const char* pszName, const char* pszFile, int n
void static inline LeaveCritical() {}
#endif
+#ifdef DEBUG_LOCKCONTENTION
+void PrintLockContention(const char* pszName, const char* pszFile, int nLine);
+#endif
+
/** Wrapper around boost::interprocess::scoped_lock */
template<typename Mutex>
class CMutexLock
@@ -43,8 +47,7 @@ public:
#ifdef DEBUG_LOCKCONTENTION
if (!lock.try_lock())
{
- printf("LOCKCONTENTION: %s\n", pszName);
- printf("Locker: %s:%d\n", pszFile, nLine);
+ PrintLockContention(pszName, pszFile, nLine);
#endif
lock.lock();
#ifdef DEBUG_LOCKCONTENTION