mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-10 20:03:34 -03:00
Further-enforce lockordering by enforcing directly after TRY_LOCKs
This commit is contained in:
parent
2a962d4540
commit
618ee9249b
1 changed files with 11 additions and 13 deletions
24
src/sync.cpp
24
src/sync.cpp
|
@ -110,21 +110,19 @@ static void push_lock(void* c, const CLockLocation& locklocation, bool fTry)
|
||||||
|
|
||||||
(*lockstack).push_back(std::make_pair(c, locklocation));
|
(*lockstack).push_back(std::make_pair(c, locklocation));
|
||||||
|
|
||||||
if (!fTry) {
|
BOOST_FOREACH (const PAIRTYPE(void*, CLockLocation) & i, (*lockstack)) {
|
||||||
BOOST_FOREACH (const PAIRTYPE(void*, CLockLocation) & i, (*lockstack)) {
|
if (i.first == c)
|
||||||
if (i.first == c)
|
break;
|
||||||
break;
|
|
||||||
|
|
||||||
std::pair<void*, void*> p1 = std::make_pair(i.first, c);
|
std::pair<void*, void*> p1 = std::make_pair(i.first, c);
|
||||||
if (lockdata.lockorders.count(p1))
|
if (lockdata.lockorders.count(p1))
|
||||||
continue;
|
continue;
|
||||||
lockdata.lockorders[p1] = (*lockstack);
|
lockdata.lockorders[p1] = (*lockstack);
|
||||||
|
|
||||||
std::pair<void*, void*> p2 = std::make_pair(c, i.first);
|
std::pair<void*, void*> p2 = std::make_pair(c, i.first);
|
||||||
lockdata.invlockorders.insert(p2);
|
lockdata.invlockorders.insert(p2);
|
||||||
if (lockdata.lockorders.count(p2))
|
if (lockdata.lockorders.count(p2))
|
||||||
potential_deadlock_detected(p1, lockdata.lockorders[p2], lockdata.lockorders[p1]);
|
potential_deadlock_detected(p1, lockdata.lockorders[p2], lockdata.lockorders[p1]);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue