diff options
author | Gavin Andresen <gavinandresen@gmail.com> | 2012-01-23 13:15:43 -0500 |
---|---|---|
committer | Gavin Andresen <gavinandresen@gmail.com> | 2012-01-23 13:15:43 -0500 |
commit | a702ceaafca55ab665058eae57c1a5a40921b866 (patch) | |
tree | f7b00d314033c21d5eb54608c93e2ae5c2488111 /src | |
parent | 9ef59797afa44957be716f8830c23f587e490945 (diff) | |
parent | 198fb229a4196aebe264a9fb10558db394e386c5 (diff) |
Merge branch 'lockcontention' of https://github.com/TheBlueMatt/bitcoin
Diffstat (limited to 'src')
-rw-r--r-- | src/util.cpp | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/src/util.cpp b/src/util.cpp index 67e1bf801a..6a4c2a2ef3 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -1153,7 +1153,18 @@ static void pop_lock() void CCriticalSection::Enter(const char* pszName, const char* pszFile, int nLine) { push_lock(this, CLockLocation(pszName, pszFile, nLine)); +#ifdef DEBUG_LOCKCONTENTION + bool result = mutex.try_lock(); + if (!result) + { + printf("LOCKCONTENTION: %s\n", pszName); + printf("Locker: %s:%d\n", pszFile, nLine); + mutex.lock(); + printf("Locked\n"); + } +#else mutex.lock(); +#endif } void CCriticalSection::Leave() { @@ -1170,9 +1181,19 @@ bool CCriticalSection::TryEnter(const char* pszName, const char* pszFile, int nL #else -void CCriticalSection::Enter(const char*, const char*, int) +void CCriticalSection::Enter(const char* pszName, const char* pszFile, int nLine) { +#ifdef DEBUG_LOCKCONTENTION + bool result = mutex.try_lock(); + if (!result) + { + printf("LOCKCONTENTION: %s\n", pszName); + printf("Locker: %s:%d\n", pszFile, nLine); + mutex.lock(); + } +#else mutex.lock(); +#endif } void CCriticalSection::Leave() |