diff --git a/src/sync.cpp b/src/sync.cpp index 9351417d43..ef46bbb22f 100644 --- a/src/sync.cpp +++ b/src/sync.cpp @@ -9,6 +9,7 @@ #include #include +#include #include #include #include @@ -27,10 +28,9 @@ #if !defined(HAVE_THREAD_LOCAL) static_assert(false, "thread_local is not supported"); #endif -void PrintLockContention(const char* pszName, const char* pszFile, int nLine) +void LockContention(const char* pszName, const char* pszFile, int nLine) { - LogPrint(BCLog::LOCK, "LOCKCONTENTION: %s\n", pszName); - LogPrint(BCLog::LOCK, "Locker: %s:%d\n", pszFile, nLine); + LOG_TIME_MICROS_WITH_CATEGORY(strprintf("%s, %s:%d", pszName, pszFile, nLine), BCLog::LOCK); } #endif /* DEBUG_LOCKCONTENTION */ diff --git a/src/sync.h b/src/sync.h index 146c228592..f4f6ece41d 100644 --- a/src/sync.h +++ b/src/sync.h @@ -127,7 +127,8 @@ using RecursiveMutex = AnnotatedMixin; typedef AnnotatedMixin Mutex; #ifdef DEBUG_LOCKCONTENTION -void PrintLockContention(const char* pszName, const char* pszFile, int nLine); +/** Prints a lock contention to the log */ +void LockContention(const char* pszName, const char* pszFile, int nLine); #endif /** Wrapper around std::unique_lock style lock for Mutex. */ @@ -140,7 +141,7 @@ private: EnterCritical(pszName, pszFile, nLine, Base::mutex()); #ifdef DEBUG_LOCKCONTENTION if (!Base::try_lock()) { - PrintLockContention(pszName, pszFile, nLine); + LockContention(pszName, pszFile, nLine); // log the contention #endif Base::lock(); #ifdef DEBUG_LOCKCONTENTION