aboutsummaryrefslogtreecommitdiff
path: root/src/net.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2017-02-08 14:46:35 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2017-02-08 14:46:43 +0100
commitdd163f57886991f3d564c9b0b1bf2ccc8f4ba784 (patch)
tree38a182fcb34ffc35c3eb59ce96c5e170e0bc3980 /src/net.cpp
parent6a55515a9b8f3cd438c9b851131d18ebb13f1a58 (diff)
parent618ee9249b178d94911ea66cb4b5291f000ef1fb (diff)
Merge #9674: Always enforce strict lock ordering (try or not)
618ee92 Further-enforce lockordering by enforcing directly after TRY_LOCKs (Matt Corallo) 2a962d4 Fixup style a bit by moving { to the same line as if statements (Matt Corallo) 8465631 Always enforce lock strict lock ordering (try or not) (Matt Corallo) fd13eca Lock cs_vSend and cs_inventory in a consistent order even in TRY (Matt Corallo)
Diffstat (limited to 'src/net.cpp')
-rw-r--r--src/net.cpp18
1 files changed, 8 insertions, 10 deletions
diff --git a/src/net.cpp b/src/net.cpp
index 4d0d781d6d..2242afb863 100644
--- a/src/net.cpp
+++ b/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);
}