| 1440 | public: |
| 1441 | CNetCleanup() {} |
| 1442 | ~CNetCleanup() { |
| 1443 | // Close sockets |
| 1444 | for (auto pNode : vNodes) |
| 1445 | if (pNode->hSocket != INVALID_SOCKET) |
| 1446 | closesocket(pNode->hSocket); |
| 1447 | for (auto hListenSocket : vhListenSocket) |
| 1448 | if (hListenSocket != INVALID_SOCKET) |
| 1449 | if (closesocket(hListenSocket) == SOCKET_ERROR) |
| 1450 | LogPrint(BCLog::INFO, "closesocket(hListenSocket) failed with error %s\n", |
| 1451 | NetworkErrorString(WSAGetLastError())); |
| 1452 | |
| 1453 | // clean up some globals (to help leak detection) |
| 1454 | for (auto pNode : vNodes) |
| 1455 | delete pNode; |
| 1456 | for (auto pNode : vNodesDisconnected) |
| 1457 | delete pNode; |
| 1458 | vNodes.clear(); |
| 1459 | vNodesDisconnected.clear(); |
| 1460 | delete semOutbound; |
| 1461 | semOutbound = nullptr; |
| 1462 | delete pnodeLocalHost; |
| 1463 | pnodeLocalHost = nullptr; |
| 1464 | |
| 1465 | #ifdef WIN32 |
| 1466 | // Shutdown Windows Sockets |
| 1467 | WSACleanup(); |
| 1468 | #endif |
| 1469 | } |
| 1470 | } |
| 1471 | |
| 1472 | instance_of_cnetcleanup; |
nothing calls this directly
no test coverage detected