Skip to content

Commit a2c0483

Browse files
committed
rename and de-globalize nUserMaxConnections
1 parent fe76929 commit a2c0483

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

src/init.cpp

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -820,7 +820,6 @@ void InitLogging(const ArgsManager& args)
820820
namespace { // Variables internal to initialization process only
821821

822822
int nMaxConnections;
823-
int nUserMaxConnections;
824823
int available_fds;
825824
ServiceFlags nLocalServices = ServiceFlags(NODE_NETWORK_LIMITED | NODE_WITNESS);
826825
int64_t peer_connect_timeout;
@@ -974,15 +973,15 @@ bool AppInitParameterInteraction(const ArgsManager& args)
974973
// Number of bound interfaces (we have at least one)
975974
int nBind = std::max(nUserBind, size_t(1));
976975
// Maximum number of connections with other nodes, this accounts for all types of outbounds and inbounds except for manual
977-
nUserMaxConnections = args.GetIntArg("-maxconnections", DEFAULT_MAX_PEER_CONNECTIONS);
978-
if (nUserMaxConnections < 0){
976+
int user_max_connections = args.GetIntArg("-maxconnections", DEFAULT_MAX_PEER_CONNECTIONS);
977+
if (user_max_connections < 0){
979978
return InitError(Untranslated("-maxconnections must be greater or equal than zero"));
980979
}
981980
// Reserve enough FDs to account for the bare minimum, plus any manual connections, plus the bound interfaces
982981
int min_required_fds = MIN_CORE_FDS + MAX_ADDNODE_CONNECTIONS + nBind;
983982

984983
// Try raising the FD limit to what we need (available_fds may be smaller than the requested amount if this fails)
985-
available_fds = RaiseFileDescriptorLimit(nUserMaxConnections + min_required_fds);
984+
available_fds = RaiseFileDescriptorLimit(user_max_connections + min_required_fds);
986985
// If we are using select instead of poll, our actual limit may be even smaller
987986
#ifndef USE_POLL
988987
available_fds = std::min(FD_SETSIZE, available_fds);
@@ -991,10 +990,10 @@ bool AppInitParameterInteraction(const ArgsManager& args)
991990
return InitError(strprintf(_("Not enough file descriptors available. %d available, %d required."), available_fds, min_required_fds));
992991

993992
// Trim requested connection counts, to fit into system limitations
994-
nMaxConnections = std::min(available_fds - min_required_fds, nUserMaxConnections);
993+
nMaxConnections = std::min(available_fds - min_required_fds, user_max_connections);
995994

996-
if (nMaxConnections < nUserMaxConnections)
997-
InitWarning(strprintf(_("Reducing -maxconnections from %d to %d, because of system limitations."), nUserMaxConnections, nMaxConnections));
995+
if (nMaxConnections < user_max_connections)
996+
InitWarning(strprintf(_("Reducing -maxconnections from %d to %d, because of system limitations."), user_max_connections, nMaxConnections));
998997

999998
// ********************************************************* Step 3: parameter-to-internal-flags
1000999
if (auto result{init::SetLoggingCategories(args)}; !result) return InitError(util::ErrorString(result));

0 commit comments

Comments
 (0)