diff options
author | Cory Fields <cory-nospam-@coryfields.com> | 2018-02-01 10:29:15 -0500 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2018-02-01 19:22:19 +0100 |
commit | e54c1ac110664efd58b7351139da55284f58f2ca (patch) | |
tree | 7ae5851976d5d5d469c0c22531191c112b9f0a90 | |
parent | 6c2788c7c8d45ac8f38e998c8a9739efdd0b6d18 (diff) | |
download | bitcoin-e54c1ac110664efd58b7351139da55284f58f2ca.tar.xz |
net: initialize socket to avoid closing random fd's
Github-Pull: #12326
Rebased-From: 96dbd381cf0ded169406bab3b1ba911a13d563c5
Tree-SHA512: 8b4a09974060e6d0992e7b9ec06c5de3ad2daf970c4484077fda803f37d3ed874dcb6fec226107b2aa0fa64cfe4116604ca4f90599430fcc622bbb805be55e1b
-rw-r--r-- | src/net.cpp | 2 | ||||
-rw-r--r-- | src/netbase.cpp | 3 |
2 files changed, 4 insertions, 1 deletions
diff --git a/src/net.cpp b/src/net.cpp index 8111390749..f407add091 100644 --- a/src/net.cpp +++ b/src/net.cpp @@ -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; diff --git a/src/netbase.cpp b/src/netbase.cpp index 276b2f4dc2..d51277c495 100644 --- a/src/netbase.cpp +++ b/src/netbase.cpp @@ -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; } |