Browse Source

net: initialize socket to avoid closing random fd's

Github-Pull: #12326
Rebased-From: 96dbd381cf0ded169406bab3b1ba911a13d563c5
Tree-SHA512: 8b4a09974060e6d0992e7b9ec06c5de3ad2daf970c4484077fda803f37d3ed874dcb6fec226107b2aa0fa64cfe4116604ca4f90599430fcc622bbb805be55e1b
0.16
Cory Fields 7 years ago committed by Wladimir J. van der Laan
parent
commit
e54c1ac110
No known key found for this signature in database
GPG Key ID: 1E4AED62986CD25D
  1. 2
      src/net.cpp
  2. 3
      src/netbase.cpp

2
src/net.cpp

@ -410,7 +410,7 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo @@ -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
src/netbase.cpp

@ -682,6 +682,9 @@ bool CloseSocket(SOCKET& hSocket) @@ -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;
}

Loading…
Cancel
Save