Put lock logging behind DEBUG_LOCKCONTENTION preprocessor directive

This commit is contained in:
Jon Atack
2022-04-01 12:23:01 +02:00
parent 7ab9fc32d6
commit 39a34b6877
6 changed files with 18 additions and 6 deletions

View File

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