mirror of
https://github.com/dashpay/dash.git
synced 2024-12-27 13:03:17 +01:00
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.
This commit is contained in:
parent
1729c29ded
commit
9e3b2f576b
27
src/net.cpp
27
src/net.cpp
@ -446,24 +446,19 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo
|
|||||||
SplitHostPort(std::string(pszDest), port, host);
|
SplitHostPort(std::string(pszDest), port, host);
|
||||||
connected = ConnectThroughProxy(proxy, host, port, hSocket, nConnectTimeout, nullptr);
|
connected = ConnectThroughProxy(proxy, host, port, hSocket, nConnectTimeout, nullptr);
|
||||||
}
|
}
|
||||||
if (connected) {
|
if (!connected) {
|
||||||
if (!IsSelectableSocket(hSocket)) {
|
CloseSocket(hSocket);
|
||||||
LogPrintf("Cannot create connection: non-selectable socket created (fd >= FD_SETSIZE ?)\n");
|
return nullptr;
|
||||||
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;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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()
|
void CConnman::DumpBanlist()
|
||||||
|
@ -465,6 +465,12 @@ SOCKET CreateSocket(const CService &addrConnect)
|
|||||||
if (hSocket == INVALID_SOCKET)
|
if (hSocket == INVALID_SOCKET)
|
||||||
return INVALID_SOCKET;
|
return INVALID_SOCKET;
|
||||||
|
|
||||||
|
if (!IsSelectableSocket(hSocket)) {
|
||||||
|
CloseSocket(hSocket);
|
||||||
|
LogPrintf("Cannot create connection: non-selectable socket created (fd >= FD_SETSIZE ?)\n");
|
||||||
|
return INVALID_SOCKET;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef SO_NOSIGPIPE
|
#ifdef SO_NOSIGPIPE
|
||||||
int set = 1;
|
int set = 1;
|
||||||
// Different way of disabling SIGPIPE on BSD
|
// Different way of disabling SIGPIPE on BSD
|
||||||
|
Loading…
Reference in New Issue
Block a user