aboutsummaryrefslogtreecommitdiff
path: root/src/net.cpp
diff options
context:
space:
mode:
authorCory Fields <[email protected]>2017-10-02 14:18:32 -0400
committerCory Fields <[email protected]>2017-12-12 15:25:25 -0500
commit9e3b2f576bb368a0857e808dcbd24b2dcb8bef2d (patch)
tree94370b8776d0bb11a6cb376fb5f94317a59b7b92 /src/net.cpp
parentnet: split socket creation out of connection (diff)
downloaddiscoin-9e3b2f576bb368a0857e808dcbd24b2dcb8bef2d.tar.xz
discoin-9e3b2f576bb368a0857e808dcbd24b2dcb8bef2d.zip
net: Move IsSelectableSocket check into socket creation
We use select in ConnectSocketDirectly, so this check needs to happen before that. IsSelectableSocket will not be relevant after upcoming changes to remove select.
Diffstat (limited to 'src/net.cpp')
-rw-r--r--src/net.cpp27
1 files changed, 11 insertions, 16 deletions
diff --git a/src/net.cpp b/src/net.cpp
index 8f1584215..07128a034 100644
--- a/src/net.cpp
+++ b/src/net.cpp
@@ -446,24 +446,19 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo
SplitHostPort(std::string(pszDest), port, host);
connected = ConnectThroughProxy(proxy, host, port, hSocket, nConnectTimeout, nullptr);
}
- if (connected) {
- if (!IsSelectableSocket(hSocket)) {
- LogPrintf("Cannot create connection: non-selectable socket created (fd >= FD_SETSIZE ?)\n");
- CloseSocket(hSocket);
- return nullptr;
- }
-
- // Add node
- NodeId id = GetNewNodeId();
- uint64_t nonce = GetDeterministicRandomizer(RANDOMIZER_ID_LOCALHOSTNONCE).Write(id).Finalize();
- CAddress addr_bind = GetBindAddress(hSocket);
- CNode* pnode = new CNode(id, nLocalServices, GetBestHeight(), hSocket, addrConnect, CalculateKeyedNetGroup(addrConnect), nonce, addr_bind, pszDest ? pszDest : "", false);
- pnode->AddRef();
-
- return pnode;
+ if (!connected) {
+ CloseSocket(hSocket);
+ return nullptr;
}
- return nullptr;
+ // Add node
+ NodeId id = GetNewNodeId();
+ uint64_t nonce = GetDeterministicRandomizer(RANDOMIZER_ID_LOCALHOSTNONCE).Write(id).Finalize();
+ CAddress addr_bind = GetBindAddress(hSocket);
+ CNode* pnode = new CNode(id, nLocalServices, GetBestHeight(), hSocket, addrConnect, CalculateKeyedNetGroup(addrConnect), nonce, addr_bind, pszDest ? pszDest : "", false);
+ pnode->AddRef();
+
+ return pnode;
}
void CConnman::DumpBanlist()