diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2011-09-03 09:09:34 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2011-09-03 09:09:34 +0200 |
commit | 0a70a3f4d88ad8e4ab689bacff4eda0cdfa88e65 (patch) | |
tree | 57a05ca259341308e9f97404d4941d1319714585 /src/util.cpp | |
parent | 0aca8577b55d218f72c7383b2464ca07b7f77d0d (diff) | |
parent | 7464e647decace52bc075d9ac8788974504e0bb9 (diff) |
Merge branch 'master' of https://github.com/bitcoin/bitcoin
Diffstat (limited to 'src/util.cpp')
-rw-r--r-- | src/util.cpp | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/util.cpp b/src/util.cpp index 3c53771baf..03b3d73e62 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -921,16 +921,22 @@ string FormatFullVersion() struct CLockLocation { - std::string mutexName; - std::string sourceFile; - int sourceLine; - CLockLocation(const char* pszName, const char* pszFile, int nLine) { mutexName = pszName; sourceFile = pszFile; sourceLine = nLine; } + + std::string ToString() const + { + return mutexName+" "+sourceFile+":"+itostr(sourceLine); + } + +private: + std::string mutexName; + std::string sourceFile; + int sourceLine; }; typedef std::vector< std::pair<CCriticalSection*, CLockLocation> > LockStack; @@ -948,14 +954,14 @@ static void potential_deadlock_detected(const std::pair<CCriticalSection*, CCrit { if (i.first == mismatch.first) printf(" (1)"); if (i.first == mismatch.second) printf(" (2)"); - printf(" %s %s:%d\n", i.second.mutexName.c_str(), i.second.sourceFile.c_str(), i.second.sourceLine); + printf(" %s\n", i.second.ToString().c_str()); } printf("Current lock order is:\n"); BOOST_FOREACH(const PAIRTYPE(CCriticalSection*, CLockLocation)& i, s1) { if (i.first == mismatch.first) printf(" (1)"); if (i.first == mismatch.second) printf(" (2)"); - printf(" %s %s:%d\n", i.second.mutexName.c_str(), i.second.sourceFile.c_str(), i.second.sourceLine); + printf(" %s\n", i.second.ToString().c_str()); } } @@ -965,6 +971,7 @@ static void push_lock(CCriticalSection* c, const CLockLocation& locklocation) if (lockstack.get() == NULL) lockstack.reset(new LockStack); + if (fDebug) printf("Locking: %s\n", locklocation.ToString().c_str()); dd_mutex.lock(); (*lockstack).push_back(std::make_pair(c, locklocation)); @@ -990,7 +997,14 @@ static void push_lock(CCriticalSection* c, const CLockLocation& locklocation) static void pop_lock() { + if (fDebug) + { + const CLockLocation& locklocation = (*lockstack).rbegin()->second; + printf("Unlocked: %s\n", locklocation.ToString().c_str()); + } + dd_mutex.lock(); (*lockstack).pop_back(); + dd_mutex.unlock(); } void CCriticalSection::Enter(const char* pszName, const char* pszFile, int nLine) |