X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fsocketengine.cpp;h=58e15af4444bcc936fc353ed164687c3e0ed947f;hb=63e300ed082b82530ad5ae0949f45686746b7c9b;hp=3735e7530aa899c65567953bce30f109aa39765c;hpb=ff3b706b2506d7614bce5e54bc88657bd62ebd4d;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/socketengine.cpp b/src/socketengine.cpp index 3735e7530..58e15af44 100644 --- a/src/socketengine.cpp +++ b/src/socketengine.cpp @@ -21,8 +21,10 @@ */ +#include "exitcodes.h" #include "inspircd.h" +#include /** Reference table, contains all current handlers **/ @@ -36,7 +38,7 @@ size_t SocketEngine::CurrentSetSize = 0; */ std::set SocketEngine::trials; -int SocketEngine::MAX_DESCRIPTORS; +size_t SocketEngine::MaxSetSize = 0; /** Socket engine statistics: count of various events, bandwidth usage */ @@ -61,6 +63,27 @@ void EventHandler::OnEventHandlerError(int errornum) { } +void SocketEngine::InitError() +{ + std::cerr << con_red << "FATAL ERROR!" << con_reset << " Socket engine initialization failed. " << strerror(errno) << '.' << std::endl; + ServerInstance->QuickExit(EXIT_STATUS_SOCKETENGINE); +} + +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;