Browse Source

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.
0.16
Cory Fields 7 years ago
parent
commit
9e3b2f576b
  1. 7
      src/net.cpp
  2. 6
      src/netbase.cpp

7
src/net.cpp

@ -446,9 +446,7 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo @@ -446,9 +446,7 @@ 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");
if (!connected) {
CloseSocket(hSocket);
return nullptr;
}
@ -461,9 +459,6 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo @@ -461,9 +459,6 @@ CNode* CConnman::ConnectNode(CAddress addrConnect, const char *pszDest, bool fCo
pnode->AddRef();
return pnode;
}
return nullptr;
}
void CConnman::DumpBanlist()

6
src/netbase.cpp

@ -465,6 +465,12 @@ SOCKET CreateSocket(const CService &addrConnect) @@ -465,6 +465,12 @@ SOCKET CreateSocket(const CService &addrConnect)
if (hSocket == 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
int set = 1;
// Different way of disabling SIGPIPE on BSD

Loading…
Cancel
Save