Mercurial > hg > bitcoin
changeset 2738:5f7a933b4c45 draft
Merge pull request #1424 from TheBlueMatt/lockcontention
Fix DEBUG_LOCKCONTENTION
author | Pieter Wuille <pieter.wuille@gmail.com> |
---|---|
date | Fri, 08 Jun 2012 07:22:19 -0700 |
parents | f51444eafc8f (current diff) d6fbfce3fe40 (diff) |
children | d52f6bf2c726 |
files | |
diffstat | 2 files changed, 13 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/src/sync.cpp +++ b/src/sync.cpp @@ -7,6 +7,14 @@ #include <boost/foreach.hpp> +#ifdef DEBUG_LOCKCONTENTION +void PrintLockContention(const char* pszName, const char* pszFile, int nLine) +{ + printf("LOCKCONTENTION: %s\n", pszName); + printf("Locker: %s:%d\n", pszFile, nLine); +} +#endif /* DEBUG_LOCKCONTENTION */ + #ifdef DEBUG_LOCKORDER // // Early deadlock detection.
--- a/src/sync.h +++ b/src/sync.h @@ -27,6 +27,10 @@ void static inline LeaveCritical() {} #endif +#ifdef DEBUG_LOCKCONTENTION +void PrintLockContention(const char* pszName, const char* pszFile, int nLine); +#endif + /** Wrapper around boost::interprocess::scoped_lock */ template<typename Mutex> class CMutexLock @@ -43,8 +47,7 @@ #ifdef DEBUG_LOCKCONTENTION if (!lock.try_lock()) { - printf("LOCKCONTENTION: %s\n", pszName); - printf("Locker: %s:%d\n", pszFile, nLine); + PrintLockContention(pszName, pszFile, nLine); #endif lock.lock(); #ifdef DEBUG_LOCKCONTENTION