|
|
@ -61,11 +61,6 @@ |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
namespace { |
|
|
|
|
|
|
|
const int MAX_FEELER_CONNECTIONS = 1; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const static std::string NET_MESSAGE_COMMAND_OTHER = "*other*"; |
|
|
|
const static std::string NET_MESSAGE_COMMAND_OTHER = "*other*"; |
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
@ -971,7 +966,7 @@ void CConnman::AcceptConnection(const ListenSocket& hListenSocket) { |
|
|
|
SOCKET hSocket = accept(hListenSocket.socket, (struct sockaddr*)&sockaddr, &len); |
|
|
|
SOCKET hSocket = accept(hListenSocket.socket, (struct sockaddr*)&sockaddr, &len); |
|
|
|
CAddress addr; |
|
|
|
CAddress addr; |
|
|
|
int nInbound = 0; |
|
|
|
int nInbound = 0; |
|
|
|
int nMaxInbound = nMaxConnections - (nMaxOutbound + MAX_FEELER_CONNECTIONS); |
|
|
|
int nMaxInbound = nMaxConnections - (nMaxOutbound + nMaxFeeler); |
|
|
|
assert(nMaxInbound > 0); |
|
|
|
assert(nMaxInbound > 0); |
|
|
|
|
|
|
|
|
|
|
|
if (hSocket != INVALID_SOCKET) |
|
|
|
if (hSocket != INVALID_SOCKET) |
|
|
@ -1624,7 +1619,7 @@ void CConnman::ThreadOpenConnections() |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
assert(nOutbound <= (nMaxOutbound + MAX_FEELER_CONNECTIONS)); |
|
|
|
assert(nOutbound <= (nMaxOutbound + nMaxFeeler)); |
|
|
|
|
|
|
|
|
|
|
|
// Feeler Connections
|
|
|
|
// Feeler Connections
|
|
|
|
//
|
|
|
|
//
|
|
|
@ -2060,6 +2055,7 @@ bool CConnman::Start(boost::thread_group& threadGroup, CScheduler& scheduler, st |
|
|
|
nLocalServices = connOptions.nLocalServices; |
|
|
|
nLocalServices = connOptions.nLocalServices; |
|
|
|
nMaxConnections = connOptions.nMaxConnections; |
|
|
|
nMaxConnections = connOptions.nMaxConnections; |
|
|
|
nMaxOutbound = std::min((connOptions.nMaxOutbound), nMaxConnections); |
|
|
|
nMaxOutbound = std::min((connOptions.nMaxOutbound), nMaxConnections); |
|
|
|
|
|
|
|
nMaxFeeler = connOptions.nMaxFeeler; |
|
|
|
|
|
|
|
|
|
|
|
nSendBufferMaxSize = connOptions.nSendBufferMaxSize; |
|
|
|
nSendBufferMaxSize = connOptions.nSendBufferMaxSize; |
|
|
|
nReceiveFloodSize = connOptions.nSendBufferMaxSize; |
|
|
|
nReceiveFloodSize = connOptions.nSendBufferMaxSize; |
|
|
@ -2106,7 +2102,7 @@ bool CConnman::Start(boost::thread_group& threadGroup, CScheduler& scheduler, st |
|
|
|
|
|
|
|
|
|
|
|
if (semOutbound == NULL) { |
|
|
|
if (semOutbound == NULL) { |
|
|
|
// initialize semaphore
|
|
|
|
// initialize semaphore
|
|
|
|
semOutbound = new CSemaphore(std::min((nMaxOutbound + MAX_FEELER_CONNECTIONS), nMaxConnections)); |
|
|
|
semOutbound = new CSemaphore(std::min((nMaxOutbound + nMaxFeeler), nMaxConnections)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (pnodeLocalHost == NULL) { |
|
|
|
if (pnodeLocalHost == NULL) { |
|
|
@ -2162,7 +2158,7 @@ void CConnman::Stop() |
|
|
|
{ |
|
|
|
{ |
|
|
|
LogPrintf("%s\n",__func__); |
|
|
|
LogPrintf("%s\n",__func__); |
|
|
|
if (semOutbound) |
|
|
|
if (semOutbound) |
|
|
|
for (int i=0; i<(nMaxOutbound + MAX_FEELER_CONNECTIONS); i++) |
|
|
|
for (int i=0; i<(nMaxOutbound + nMaxFeeler); i++) |
|
|
|
semOutbound->post(); |
|
|
|
semOutbound->post(); |
|
|
|
|
|
|
|
|
|
|
|
if (fAddressesInitialized) |
|
|
|
if (fAddressesInitialized) |
|
|
|