Skip to content

Commit

Permalink
sync: remove DEBUG_LOCKCONTENTION preprocessor directives
Browse files Browse the repository at this point in the history
  • Loading branch information
jonatack committed Aug 18, 2021
1 parent 2970b6b commit ccd73de
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
6 changes: 0 additions & 6 deletions src/sync.cpp
Expand Up @@ -23,12 +23,6 @@
#include <utility>
#include <vector>

#ifdef DEBUG_LOCKCONTENTION
#if !defined(HAVE_THREAD_LOCAL)
static_assert(false, "thread_local is not supported");
#endif
#endif /* DEBUG_LOCKCONTENTION */

#ifdef DEBUG_LOCKORDER
//
// Early deadlock detection.
Expand Down
14 changes: 9 additions & 5 deletions src/sync.h
Expand Up @@ -137,13 +137,17 @@ class SCOPED_LOCKABLE UniqueLock : public Base
void Enter(const char* pszName, const char* pszFile, int nLine)
{
EnterCritical(pszName, pszFile, nLine, Base::mutex());
#ifdef DEBUG_LOCKCONTENTION
if (!Base::try_lock()) {
LogPrint(BCLog::LOCK, "Lock contention: %s, %s:%d\n", pszName, pszFile, nLine);
#endif
#if defined(HAVE_THREAD_LOCAL)
if (LogAcceptCategory(BCLog::LOCK)) {
if (!Base::try_lock()) {
LogPrint(BCLog::LOCK, "Lock contention: %s, %s:%d\n", pszName, pszFile, nLine);
Base::lock();
}
} else {
Base::lock();
#ifdef DEBUG_LOCKCONTENTION
}
#else
Base::lock();
#endif
}

Expand Down

0 comments on commit ccd73de

Please sign in to comment.