diff options
author | Attila Molnar <attilamolnar@hush.com> | 2014-06-07 13:47:26 +0200 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2014-06-07 13:47:26 +0200 |
commit | 5a6fd54f8fd217232f98804431928609580742bc (patch) | |
tree | 8bed7bfab1526fcd1ef691d2483cbb9400dcfd72 /src/socketengines | |
parent | 76f1ba946972dbff089b27d64748afc1c0d95c6a (diff) |
Change the number reported by SocketEngine::GetMaxFds() to be informal
Do not exit if we can't determine it
Diffstat (limited to 'src/socketengines')
-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 |
4 files changed, 8 insertions, 32 deletions
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) |