aboutsummaryrefslogtreecommitdiff
path: root/src/sync.h
diff options
context:
space:
mode:
authorJon Atack <jon@atack.com>2021-08-18 19:53:42 +0200
committerJon Atack <jon@atack.com>2021-09-01 15:25:38 +0200
commit9b08006bc502e67956d6ab518388fad6397cac8d (patch)
treec91ff6a05c64c14fe7b6085ec9a5008c37061871 /src/sync.h
parent3f4c6b87f1098436693c4990f2082515ec0ece26 (diff)
downloadbitcoin-9b08006bc502e67956d6ab518388fad6397cac8d.tar.xz
log, sync: improve lock contention logging and add time duration
in microseconds. Change the function name in order to print "LockContention" instead of "PrintLockContention" to the log. Add Doxygen documentation. With this change, the lock contention log prints: 2021-09-01T11:29:03Z LockContention: pnode->cs_vSend, net.cpp:1373 started 2021-09-01T11:29:03Z LockContention: pnode->cs_vSend, net.cpp:1373 completed (31μs) 2021-09-01T11:29:03Z LockContention: cs_vNodes, net.cpp:2277 started 2021-09-01T11:29:03Z LockContention: cs_vNodes, net.cpp:2277 completed (6μs) 2021-09-01T11:29:04Z LockContention: cs_vNodes, net.cpp:2242 started 2021-09-01T11:29:04Z LockContention: cs_vNodes, net.cpp:2242 completed (3μs) Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> Co-authored-by: practicalswift <practicalswift@users.noreply.github.com>
Diffstat (limited to 'src/sync.h')
-rw-r--r--src/sync.h5
1 files changed, 3 insertions, 2 deletions
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<std::recursive_mutex>;
typedef AnnotatedMixin<std::mutex> 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