From 8d2f847ed913f15677ae978a412015ac844ffceb Mon Sep 17 00:00:00 2001 From: Jon Atack Date: Mon, 6 Sep 2021 20:59:58 +0200 Subject: sync: inline lock contention logging macro to fix time duration Co-authored-by: Martin Ankerl --- src/sync.cpp | 6 ------ src/sync.h | 7 +++---- 2 files changed, 3 insertions(+), 10 deletions(-) (limited to 'src') diff --git a/src/sync.cpp b/src/sync.cpp index eace86d9dd..98e6d3d65d 100644 --- a/src/sync.cpp +++ b/src/sync.cpp @@ -9,7 +9,6 @@ #include #include -#include #include #include #include @@ -24,11 +23,6 @@ #include #include -void LockContention(const char* pszName, const char* pszFile, int nLine) -{ - LOG_TIME_MICROS_WITH_CATEGORY(strprintf("%s, %s:%d", pszName, pszFile, nLine), BCLog::LOCK); -} - #ifdef DEBUG_LOCKORDER // // Early deadlock detection. diff --git a/src/sync.h b/src/sync.h index bf15c0b4eb..6ba63d5e4d 100644 --- a/src/sync.h +++ b/src/sync.h @@ -6,6 +6,8 @@ #ifndef BITCOIN_SYNC_H #define BITCOIN_SYNC_H +#include +#include #include #include @@ -126,9 +128,6 @@ using RecursiveMutex = AnnotatedMixin; /** Wrapped mutex: supports waiting but not recursive locking */ typedef AnnotatedMixin Mutex; -/** Prints a lock contention to the log */ -void LockContention(const char* pszName, const char* pszFile, int nLine); - /** Wrapper around std::unique_lock style lock for Mutex. */ template class SCOPED_LOCKABLE UniqueLock : public Base @@ -138,7 +137,7 @@ private: { EnterCritical(pszName, pszFile, nLine, Base::mutex()); if (Base::try_lock()) return; - LockContention(pszName, pszFile, nLine); // log the contention + LOG_TIME_MICROS_WITH_CATEGORY(strprintf("lock contention %s, %s:%d", pszName, pszFile, nLine), BCLog::LOCK); Base::lock(); } -- cgit v1.2.3