net: initialize socket to avoid closing random fd's

This commit is contained in:
Cory Fields committed 2018-02-01 11:31:27 -05:00
1 parent 895fbd768f
commit 96dbd381cf
2 files changed
+4 -1

No files matched your search

+1 -1
View File
@@ -410,7 +410,7 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo
// Connect
bool connected = false;
SOCKET hSocket;
SOCKET hSocket = INVALID_SOCKET;
proxyType proxy;
if (addrConnect.IsValid()) {
bool proxyConnectionFailed = false;
+3
View File
@@ -682,6 +682,9 @@ bool CloseSocket(SOCKET& hSocket)
#else
int ret = close(hSocket);
#endif
if (ret) {
LogPrintf("Socket close failed: %d. Error: %s\n", hSocket, NetworkErrorString(WSAGetLastError()));
}
hSocket = INVALID_SOCKET;
return ret != SOCKET_ERROR;
}