Skip to content

Commit

Permalink
Further-enforce lockordering by enforcing directly after TRY_LOCKs
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBlueMatt committed Feb 7, 2017
1 parent 2a962d4 commit 618ee92
Showing 1 changed file with 13 additions and 15 deletions.
28 changes: 13 additions & 15 deletions src/sync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,21 +110,19 @@ static void push_lock(void* c, const CLockLocation& locklocation, bool fTry)

(*lockstack).push_back(std::make_pair(c, locklocation));

if (!fTry) {
BOOST_FOREACH (const PAIRTYPE(void*, CLockLocation) & i, (*lockstack)) {
if (i.first == c)
break;

std::pair<void*, void*> p1 = std::make_pair(i.first, c);
if (lockdata.lockorders.count(p1))
continue;
lockdata.lockorders[p1] = (*lockstack);

std::pair<void*, void*> p2 = std::make_pair(c, i.first);
lockdata.invlockorders.insert(p2);
if (lockdata.lockorders.count(p2))
potential_deadlock_detected(p1, lockdata.lockorders[p2], lockdata.lockorders[p1]);
}
BOOST_FOREACH (const PAIRTYPE(void*, CLockLocation) & i, (*lockstack)) {
if (i.first == c)
break;

std::pair<void*, void*> p1 = std::make_pair(i.first, c);
if (lockdata.lockorders.count(p1))
continue;
lockdata.lockorders[p1] = (*lockstack);

std::pair<void*, void*> p2 = std::make_pair(c, i.first);
lockdata.invlockorders.insert(p2);
if (lockdata.lockorders.count(p2))
potential_deadlock_detected(p1, lockdata.lockorders[p2], lockdata.lockorders[p1]);
}
}

Expand Down

0 comments on commit 618ee92

Please sign in to comment.