diff options
-rw-r--r-- | include/socketengine.h | 6 | ||||
-rw-r--r-- | src/configreader.cpp | 3 | ||||
-rw-r--r-- | src/socketengines/socketengine_epoll.cpp | 13 | ||||
-rw-r--r-- | src/socketengines/socketengine_kqueue.cpp | 7 | ||||
-rw-r--r-- | src/socketengines/socketengine_poll.cpp | 6 | ||||
-rw-r--r-- | src/socketengines/socketengine_ports.cpp | 14 |
6 files changed, 13 insertions, 36 deletions
diff --git a/include/socketengine.h b/include/socketengine.h index 3a15e98c1..895457b89 100644 --- a/include/socketengine.h +++ b/include/socketengine.h @@ -346,8 +346,10 @@ public: */ static void ChangeEventMask(EventHandler* eh, int event_mask); - /** Returns the highest file descriptor you may store in the socket engine - * @return The maximum fd value + /** Returns the number of file descriptors reported by the system this program may use + * when it was started. + * @return If positive, the number of file descriptors that the system reported that we + * may use. Otherwise (<= 0) this number could not be determined. */ static int GetMaxFds() { return MAX_DESCRIPTORS; } diff --git a/src/configreader.cpp b/src/configreader.cpp index 77f61c978..15d9298b6 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -36,7 +36,6 @@ ServerConfig::ServerConfig() dns_timeout = 5; MaxTargets = 20; NetBufferSize = 10240; - SoftLimit = SocketEngine::GetMaxFds(); MaxConn = SOMAXCONN; MaxChans = 20; OperMaxChans = 30; @@ -366,7 +365,7 @@ void ServerConfig::Fill() if (!nsid.empty() && nsid != sid) throw CoreException("You must restart to change the server id"); } - SoftLimit = ConfValue("performance")->getInt("softlimit", SocketEngine::GetMaxFds(), 10, SocketEngine::GetMaxFds()); + SoftLimit = ConfValue("performance")->getInt("softlimit", (SocketEngine::GetMaxFds() > 0 ? SocketEngine::GetMaxFds() : LONG_MAX), 10); CCOnConnect = ConfValue("performance")->getBool("clonesonconnect", true); MaxConn = ConfValue("performance")->getInt("somaxconn", SOMAXCONN); XLineMessage = options->getString("xlinemessage", options->getString("moronbanner", "You're banned!")); diff --git a/src/socketengines/socketengine_epoll.cpp b/src/socketengines/socketengine_epoll.cpp index 1c4d8963d..7d919ec9f 100644 --- a/src/socketengines/socketengine_epoll.cpp +++ b/src/socketengines/socketengine_epoll.cpp @@ -42,17 +42,8 @@ namespace void SocketEngine::Init() { - int max = ulimit(4, 0); - if (max > 0) - { - MAX_DESCRIPTORS = max; - } - else - { - ServerInstance->Logs->Log("SOCKET", LOG_DEFAULT, "ERROR: Can't determine maximum number of open sockets!"); - std::cout << "ERROR: Can't determine maximum number of open sockets!" << std::endl; - ServerInstance->QuickExit(EXIT_STATUS_SOCKETENGINE); - } + // MAX_DESCRIPTORS is mainly used for display purposes, no problem if ulimit() fails and returns a negative number + MAX_DESCRIPTORS = ulimit(4, 0); // 128 is not a maximum, just a hint at the eventual number of sockets that may be polled, // and it is completely ignored by 2.6.8 and later kernels, except it must be larger than zero. diff --git a/src/socketengines/socketengine_kqueue.cpp b/src/socketengines/socketengine_kqueue.cpp index 68c1bda8c..d5a3bb793 100644 --- a/src/socketengines/socketengine_kqueue.cpp +++ b/src/socketengines/socketengine_kqueue.cpp @@ -58,13 +58,8 @@ void SocketEngine::Init() mib[1] = KERN_MAXFILES; #endif len = sizeof(MAX_DESCRIPTORS); + // MAX_DESCRIPTORS is mainly used for display purposes, no problem if the sysctl() below fails sysctl(mib, 2, &MAX_DESCRIPTORS, &len, NULL, 0); - if (MAX_DESCRIPTORS <= 0) - { - ServerInstance->Logs->Log("SOCKET", LOG_DEFAULT, "ERROR: Can't determine maximum number of open sockets!"); - std::cout << "ERROR: Can't determine maximum number of open sockets!" << std::endl; - ServerInstance->QuickExit(EXIT_STATUS_SOCKETENGINE); - } RecoverFromFork(); } diff --git a/src/socketengines/socketengine_poll.cpp b/src/socketengines/socketengine_poll.cpp index 4eca494cf..4e6d0b9f5 100644 --- a/src/socketengines/socketengine_poll.cpp +++ b/src/socketengines/socketengine_poll.cpp @@ -21,7 +21,6 @@ */ -#include <iostream> #include <vector> #include <string> #include <map> @@ -53,9 +52,8 @@ void SocketEngine::Init() } else { - ServerInstance->Logs->Log("SOCKET", LOG_DEFAULT, "ERROR: Can't determine maximum number of open sockets: %s", strerror(errno)); - std::cout << "ERROR: Can't determine maximum number of open sockets: " << strerror(errno) << std::endl; - ServerInstance->QuickExit(EXIT_STATUS_SOCKETENGINE); + // MAX_DESCRIPTORS is mainly used for display purposes, it's not a problem that getrlimit() failed + MAX_DESCRIPTORS = -1; } } diff --git a/src/socketengines/socketengine_ports.cpp b/src/socketengines/socketengine_ports.cpp index deafd8fcb..c6ddb041c 100644 --- a/src/socketengines/socketengine_ports.cpp +++ b/src/socketengines/socketengine_ports.cpp @@ -48,17 +48,9 @@ namespace */ void SocketEngine::Init() { - int max = ulimit(4, 0); - if (max > 0) - { - MAX_DESCRIPTORS = max; - } - else - { - ServerInstance->Logs->Log("SOCKET", LOG_DEFAULT, "ERROR: Can't determine maximum number of open sockets!"); - std::cout << "ERROR: Can't determine maximum number of open sockets!" << std::endl; - ServerInstance->QuickExit(EXIT_STATUS_SOCKETENGINE); - } + // MAX_DESCRIPTORS is mainly used for display purposes, no problem if ulimit() fails and returns a negative number + MAX_DESCRIPTORS = ulimit(4, 0); + EngineHandle = port_create(); if (EngineHandle == -1) |