mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-11 06:28:31 +01:00
Merge #9674: Always enforce strict lock ordering (try or not)
618ee92Further-enforce lockordering by enforcing directly after TRY_LOCKs (Matt Corallo)2a962d4Fixup style a bit by moving { to the same line as if statements (Matt Corallo)8465631Always enforce lock strict lock ordering (try or not) (Matt Corallo)fd13ecaLock cs_vSend and cs_inventory in a consistent order even in TRY (Matt Corallo)
This commit is contained in:
18
src/net.cpp
18
src/net.cpp
@@ -1093,20 +1093,18 @@ void CConnman::ThreadSocketHandler()
|
||||
BOOST_FOREACH(CNode* pnode, vNodesDisconnectedCopy)
|
||||
{
|
||||
// wait until threads are done using it
|
||||
if (pnode->GetRefCount() <= 0)
|
||||
{
|
||||
if (pnode->GetRefCount() <= 0) {
|
||||
bool fDelete = false;
|
||||
{
|
||||
TRY_LOCK(pnode->cs_vSend, lockSend);
|
||||
if (lockSend)
|
||||
{
|
||||
TRY_LOCK(pnode->cs_inventory, lockInv);
|
||||
if (lockInv)
|
||||
fDelete = true;
|
||||
TRY_LOCK(pnode->cs_inventory, lockInv);
|
||||
if (lockInv) {
|
||||
TRY_LOCK(pnode->cs_vSend, lockSend);
|
||||
if (lockSend) {
|
||||
fDelete = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (fDelete)
|
||||
{
|
||||
if (fDelete) {
|
||||
vNodesDisconnected.remove(pnode);
|
||||
DeleteNode(pnode);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user