diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2018-02-01 19:21:05 +0100 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2018-02-01 19:21:49 +0100 |
commit | 84291d18dd69e0baff766d256a3f45f910be55e9 (patch) | |
tree | 03d9a1dcbe0a5fcef8f18ce5f859f3e57395550a | |
parent | 895fbd768f0c89cea3f78acac58b233d4e3a145e (diff) | |
parent | 96dbd381cf0ded169406bab3b1ba911a13d563c5 (diff) | |
download | bitcoin-84291d18dd69e0baff766d256a3f45f910be55e9.tar.xz |
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
-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; } |