Skip to content

Commit

Permalink
net: Combine two loops into one, and update comments
Browse files Browse the repository at this point in the history
  • Loading branch information
hebasto committed Apr 22, 2021
1 parent a3d090d commit 229ac18
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 229ac18

Please sign in to comment.