aboutsummaryrefslogtreecommitdiff
path: root/src/sync.h
diff options
context:
space:
mode:
authorJon Atack <jon@atack.com>2022-04-01 12:23:01 +0200
committerJon Atack <jon@atack.com>2022-04-05 12:49:48 +0200
commit39a34b6877945908759f6a2322f60852e521e2ee (patch)
tree7a170824a35af9d86470499730f2568f1873388b /src/sync.h
parent7ab9fc32d6a88d0c9a008d6e63ddc7460e5ea0c5 (diff)
Put lock logging behind DEBUG_LOCKCONTENTION preprocessor directive
Diffstat (limited to 'src/sync.h')
-rw-r--r--src/sync.h5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/sync.h b/src/sync.h
index 85000a9151..af7595e6fa 100644
--- a/src/sync.h
+++ b/src/sync.h
@@ -6,8 +6,11 @@
#ifndef BITCOIN_SYNC_H
#define BITCOIN_SYNC_H
+#ifdef DEBUG_LOCKCONTENTION
#include <logging.h>
#include <logging/timer.h>
+#endif
+
#include <threadsafety.h>
#include <util/macros.h>
@@ -136,8 +139,10 @@ private:
void Enter(const char* pszName, const char* pszFile, int nLine)
{
EnterCritical(pszName, pszFile, nLine, Base::mutex());
+#ifdef DEBUG_LOCKCONTENTION
if (Base::try_lock()) return;
LOG_TIME_MICROS_WITH_CATEGORY(strprintf("lock contention %s, %s:%d", pszName, pszFile, nLine), BCLog::LOCK);
+#endif
Base::lock();
}