Changeset View
Changeset View
Standalone View
Standalone View
src/init.cpp
Show First 20 Lines • Show All 1,498 Lines • ▼ Show 20 Lines | bool AppInitParameterInteraction(Config &config) { | ||||
// Make sure enough file descriptors are available | // Make sure enough file descriptors are available | ||||
int nBind = std::max(nUserBind, size_t(1)); | int nBind = std::max(nUserBind, size_t(1)); | ||||
nUserMaxConnections = | nUserMaxConnections = | ||||
gArgs.GetArg("-maxconnections", DEFAULT_MAX_PEER_CONNECTIONS); | gArgs.GetArg("-maxconnections", DEFAULT_MAX_PEER_CONNECTIONS); | ||||
nMaxConnections = std::max(nUserMaxConnections, 0); | nMaxConnections = std::max(nUserMaxConnections, 0); | ||||
// Trim requested connection counts, to fit into system limitations | // Trim requested connection counts, to fit into system limitations | ||||
nMaxConnections = | nMaxConnections = | ||||
std::max(std::min(nMaxConnections, | std::max(std::min(nMaxConnections, FD_SETSIZE - nBind - | ||||
(int)(FD_SETSIZE - nBind - MIN_CORE_FILEDESCRIPTORS - | MIN_CORE_FILEDESCRIPTORS - | ||||
MAX_ADDNODE_CONNECTIONS)), | MAX_ADDNODE_CONNECTIONS), | ||||
0); | 0); | ||||
nFD = RaiseFileDescriptorLimit(nMaxConnections + MIN_CORE_FILEDESCRIPTORS + | nFD = RaiseFileDescriptorLimit(nMaxConnections + MIN_CORE_FILEDESCRIPTORS + | ||||
MAX_ADDNODE_CONNECTIONS); | MAX_ADDNODE_CONNECTIONS); | ||||
if (nFD < MIN_CORE_FILEDESCRIPTORS) { | if (nFD < MIN_CORE_FILEDESCRIPTORS) { | ||||
return InitError(_("Not enough file descriptors available.")); | return InitError(_("Not enough file descriptors available.")); | ||||
} | } | ||||
nMaxConnections = | nMaxConnections = | ||||
std::min(nFD - MIN_CORE_FILEDESCRIPTORS - MAX_ADDNODE_CONNECTIONS, | std::min(nFD - MIN_CORE_FILEDESCRIPTORS - MAX_ADDNODE_CONNECTIONS, | ||||
▲ Show 20 Lines • Show All 994 Lines • Show Last 20 Lines |