Merge #12326: net: initialize socket to avoid closing random fd's

96dbd38 net: initialize socket to avoid closing random fd's (Cory Fields)

Pull request description:

  An excellent spot by @david60.

  Even if it isn't causing the fd issue we're looking for, this should be fixed.

Tree-SHA512: 062a8f2cdd39d895213e1263dbd7b8391473ddaea2f93c82c211a9bb6ea6744d48a6c84c8ff804b16b865d14145492635c500a9fd138d0988fee5e4f719ebb91
pull/12329/head
Wladimir J. van der Laan 7 years ago
commit 84291d18dd
No known key found for this signature in database
GPG Key ID: 1E4AED62986CD25D

@ -410,7 +410,7 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo
// Connect // Connect
bool connected = false; bool connected = false;
SOCKET hSocket; SOCKET hSocket = INVALID_SOCKET;
proxyType proxy; proxyType proxy;
if (addrConnect.IsValid()) { if (addrConnect.IsValid()) {
bool proxyConnectionFailed = false; bool proxyConnectionFailed = false;

@ -682,6 +682,9 @@ bool CloseSocket(SOCKET& hSocket)
#else #else
int ret = close(hSocket); int ret = close(hSocket);
#endif #endif
if (ret) {
LogPrintf("Socket close failed: %d. Error: %s\n", hSocket, NetworkErrorString(WSAGetLastError()));
}
hSocket = INVALID_SOCKET; hSocket = INVALID_SOCKET;
return ret != SOCKET_ERROR; return ret != SOCKET_ERROR;
} }

Loading…
Cancel
Save