aboutsummaryrefslogtreecommitdiff
path: root/src/net.cpp
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2017-07-24 14:58:25 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2017-07-24 16:54:42 +0200
commit0c70e845aa9277a4ceb8307f0ad8f1bf7511e3c8 (patch)
tree0028be401164d1db4072e20c4ae8643cf23ded86 /src/net.cpp
parent6ef3c7ec6233989e0dec6622ef905b32f94058ac (diff)
parent05e023f2ec8d8dc37bb0f20db1c606f06aea69f5 (diff)
Merge #10865: Move CloseSocket out of SetSocketNonBlocking and pass socket as const reference
05e023f Move CloseSocket out of SetSocketNonBlocking and pass SOCKET by const reference in SetSocket* functions (Dag Robole) Pull request description: Rationale: Readability, SetSocketNonBlocking does what it says on the tin. Consistency, More consistent with the rest of the API in this unit. Reusability, SetSocketNonBlocking can also be used by clients that may not want to close the socket on failure. This also moves the responsibility of closing the socket back to the caller that opened it, which in general should know better how and when to close it. Tree-SHA512: 85027137f1b626e2b636549ee38cc757a587adcf464c84be6e65ca16e3b75d7ed1a1b21dd70dbe34c7c5d599af39e53b89932dfe3c74f91a22341ff3af5ea80a
Diffstat (limited to 'src/net.cpp')
-rw-r--r--src/net.cpp1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/net.cpp b/src/net.cpp
index 5bf3af7ea3..0994af3021 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -2076,6 +2076,7 @@ bool CConnman::BindListenPort(const CService &addrBind, std::string& strError, b
// Set to non-blocking, incoming connections will also inherit this
if (!SetSocketNonBlocking(hListenSocket, true)) {
+ CloseSocket(hListenSocket);
strError = strprintf("BindListenPort: Setting listening socket to non-blocking failed, error %s\n", NetworkErrorString(WSAGetLastError()));
LogPrintf("%s\n", strError);
return false;