diff options
Diffstat (limited to 'src/net.cpp')
-rw-r--r-- | src/net.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/net.cpp b/src/net.cpp index ae38acdc3c..65f8b8baec 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -2636,8 +2636,9 @@ void CConnman::StopNodes() } // Close sockets - LOCK(cs_vNodes); - for (CNode* pnode : vNodes) + std::vector<CNode*> nodes; + WITH_LOCK(cs_vNodes, nodes.swap(vNodes)); + for (CNode* pnode : nodes) pnode->CloseSocketDisconnect(); for (ListenSocket& hListenSocket : vhListenSocket) if (hListenSocket.socket != INVALID_SOCKET) @@ -2645,13 +2646,12 @@ void CConnman::StopNodes() LogPrintf("CloseSocket(hListenSocket) failed with error %s\n", NetworkErrorString(WSAGetLastError())); // clean up some globals (to help leak detection) - for (CNode* pnode : vNodes) { + for (CNode* pnode : nodes) { DeleteNode(pnode); } for (CNode* pnode : vNodesDisconnected) { DeleteNode(pnode); } - vNodes.clear(); vNodesDisconnected.clear(); vhListenSocket.clear(); semOutbound.reset(); |