diff options
Diffstat (limited to 'src/socketengine.cpp')
-rw-r--r-- | src/socketengine.cpp | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/src/socketengine.cpp b/src/socketengine.cpp index 3735e7530..bac97a6dc 100644 --- a/src/socketengine.cpp +++ b/src/socketengine.cpp @@ -23,7 +23,6 @@ #include "inspircd.h" - /** Reference table, contains all current handlers **/ std::vector<EventHandler*> SocketEngine::ref; @@ -36,7 +35,7 @@ size_t SocketEngine::CurrentSetSize = 0; */ std::set<int> SocketEngine::trials; -int SocketEngine::MAX_DESCRIPTORS; +size_t SocketEngine::MaxSetSize = 0; /** Socket engine statistics: count of various events, bandwidth usage */ @@ -61,6 +60,21 @@ void EventHandler::OnEventHandlerError(int errornum) { } +void SocketEngine::LookupMaxFds() +{ + struct rlimit limits; + if (!getrlimit(RLIMIT_NOFILE, &limits)) + MaxSetSize = limits.rlim_cur; + +#if defined __APPLE__ + limits.rlim_cur = limits.rlim_max == RLIM_INFINITY ? OPEN_MAX : limits.rlim_max; +#else + limits.rlim_cur = limits.rlim_max; +#endif + if (!setrlimit(RLIMIT_NOFILE, &limits)) + MaxSetSize = limits.rlim_cur; +} + void SocketEngine::ChangeEventMask(EventHandler* eh, int change) { int old_m = eh->event_mask; |