diff options
author | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2021-04-12 14:54:58 +0300 |
---|---|---|
committer | Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> | 2021-04-22 17:28:39 +0300 |
commit | 229ac1892d807a1eea5a7c24ae0fe27dc913b1bd (patch) | |
tree | fdfd6016beb0ff2be24f56f828ae1bfeacc622a3 | |
parent | a3d090d1103cd6c25daf07afdf4e65febca6d3f7 (diff) |
net: Combine two loops into one, and update comments
-rw-r--r-- | src/net.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/net.cpp b/src/net.cpp index 65f8b8baec..2cb95516a4 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -2635,20 +2635,20 @@ void CConnman::StopNodes() } } - // Close sockets + // Delete peer connections. std::vector<CNode*> nodes; WITH_LOCK(cs_vNodes, nodes.swap(vNodes)); - for (CNode* pnode : nodes) + for (CNode* pnode : nodes) { pnode->CloseSocketDisconnect(); + DeleteNode(pnode); + } + + // Close listening sockets. for (ListenSocket& hListenSocket : vhListenSocket) if (hListenSocket.socket != INVALID_SOCKET) if (!CloseSocket(hListenSocket.socket)) LogPrintf("CloseSocket(hListenSocket) failed with error %s\n", NetworkErrorString(WSAGetLastError())); - // clean up some globals (to help leak detection) - for (CNode* pnode : nodes) { - DeleteNode(pnode); - } for (CNode* pnode : vNodesDisconnected) { DeleteNode(pnode); } |