Skip to content

Commit

Permalink
net: initialize socket to avoid closing random fd's
Browse files Browse the repository at this point in the history
  • Loading branch information
theuni committed Feb 1, 2018
1 parent 895fbd7 commit 96dbd38
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/net.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
3 changes: 3 additions & 0 deletions src/netbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down

0 comments on commit 96dbd38

Please sign in to comment.