aboutsummaryrefslogtreecommitdiff
path: root/src/util.cpp
diff options
context:
space:
mode:
authorGavin Andresen <[email protected]>2011-08-31 10:24:45 -0700
committerGavin Andresen <[email protected]>2011-08-31 10:24:45 -0700
commitcb6c4b883da6896b39bd46f845453f69d0f516f1 (patch)
treecc9de8e932d07cf2549a625e6c614a2677ec1b0e /src/util.cpp
parentMerge pull request #463 from TheBlueMatt/encreadme (diff)
parentFixed potential deadlocks in GUI code. (diff)
downloaddiscoin-cb6c4b883da6896b39bd46f845453f69d0f516f1.tar.xz
discoin-cb6c4b883da6896b39bd46f845453f69d0f516f1.zip
Merge pull request #480 from gavinandresen/deadlocks
Simplify mutex locking, fix deadlocks. Fixes issue #453
Diffstat (limited to 'src/util.cpp')
-rw-r--r--src/util.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/util.cpp b/src/util.cpp
index 24c7ed448..390b3a340 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;
}
}