Skip to content

Commit 4927bf2

Browse files
committed
Increase maxconnections limit when using poll.
1 parent 11cc491 commit 4927bf2

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/init.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -952,8 +952,13 @@ bool AppInitParameterInteraction()
952952

953953
// Trim requested connection counts, to fit into system limitations
954954
// <int> in std::min<int>(...) to work around FreeBSD compilation issue described in #2695
955-
nMaxConnections = std::max(std::min<int>(nMaxConnections, FD_SETSIZE - nBind - MIN_CORE_FILEDESCRIPTORS - MAX_ADDNODE_CONNECTIONS), 0);
956955
nFD = RaiseFileDescriptorLimit(nMaxConnections + MIN_CORE_FILEDESCRIPTORS + MAX_ADDNODE_CONNECTIONS);
956+
#ifdef USE_POLL
957+
int fd_max = nFD;
958+
#else
959+
int fd_max = FD_SETSIZE;
960+
#endif
961+
nMaxConnections = std::max(std::min<int>(nMaxConnections, fd_max - nBind - MIN_CORE_FILEDESCRIPTORS - MAX_ADDNODE_CONNECTIONS), 0);
957962
if (nFD < MIN_CORE_FILEDESCRIPTORS)
958963
return InitError(_("Not enough file descriptors available."));
959964
nMaxConnections = std::min(nFD - MIN_CORE_FILEDESCRIPTORS - MAX_ADDNODE_CONNECTIONS, nMaxConnections);

0 commit comments

Comments
 (0)