diff options
author | Gavin Andresen <gavinandresen@gmail.com> | 2011-08-29 17:03:08 -0400 |
---|---|---|
committer | Gavin Andresen <gavinandresen@gmail.com> | 2011-08-31 12:53:57 -0400 |
commit | b0243da77c6ee8d8ca59b4423f333a179bff02cf (patch) | |
tree | 20b48c40f423ef2a25eb3e8e33c8270e491fca05 /src/util.cpp | |
parent | 21189a42a735ff66166c17c53eb44998346059d6 (diff) |
Highlight mis-matching locks
Diffstat (limited to 'src/util.cpp')
-rw-r--r-- | src/util.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/util.cpp b/src/util.cpp index 24c7ed4487..390b3a340b 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -942,17 +942,21 @@ static std::map<std::pair<CCriticalSection*, CCriticalSection*>, LockStack> lock static boost::thread_specific_ptr<LockStack> lockstack; -static void potential_deadlock_detected(const LockStack& s1, const LockStack& s2) +static void potential_deadlock_detected(const std::pair<CCriticalSection*, CCriticalSection*>& mismatch, const LockStack& s1, const LockStack& s2) { printf("POTENTIAL DEADLOCK DETECTED\n"); printf("Previous lock order was:\n"); BOOST_FOREACH(const PAIRTYPE(CCriticalSection*, CLockLocation)& i, s2) { + 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("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); } } @@ -979,7 +983,7 @@ static void push_lock(CCriticalSection* c, const CLockLocation& locklocation) std::pair<CCriticalSection*, CCriticalSection*> p2 = std::make_pair(c, i.first); if (lockorders.count(p2)) { - potential_deadlock_detected(lockorders[p2], lockorders[p1]); + potential_deadlock_detected(p1, lockorders[p2], lockorders[p1]); break; } } |