diff options
Diffstat (limited to 'src/socketengines')
-rw-r--r-- | src/socketengines/socketengine_epoll.cpp | 4 | ||||
-rw-r--r-- | src/socketengines/socketengine_kqueue.cpp | 4 | ||||
-rw-r--r-- | src/socketengines/socketengine_poll.cpp | 44 | ||||
-rw-r--r-- | src/socketengines/socketengine_ports.cpp | 4 | ||||
-rw-r--r-- | src/socketengines/socketengine_select.cpp | 4 |
5 files changed, 21 insertions, 39 deletions
diff --git a/src/socketengines/socketengine_epoll.cpp b/src/socketengines/socketengine_epoll.cpp index 68f14cc38..099f793a1 100644 --- a/src/socketengines/socketengine_epoll.cpp +++ b/src/socketengines/socketengine_epoll.cpp @@ -63,7 +63,7 @@ EPollEngine::EPollEngine() { 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->Exit(EXIT_STATUS_SOCKETENGINE); + ServerInstance->QuickExit(EXIT_STATUS_SOCKETENGINE); } // This is not a maximum, just a hint at the eventual number of sockets that may be polled. @@ -75,7 +75,7 @@ EPollEngine::EPollEngine() ServerInstance->Logs->Log("SOCKET", LOG_DEFAULT, "ERROR: Your kernel probably does not have the proper features. This is a fatal error, exiting now."); std::cout << "ERROR: Could not initialize epoll socket engine: " << strerror(errno) << std::endl; std::cout << "ERROR: Your kernel probably does not have the proper features. This is a fatal error, exiting now." << std::endl; - ServerInstance->Exit(EXIT_STATUS_SOCKETENGINE); + ServerInstance->QuickExit(EXIT_STATUS_SOCKETENGINE); } ref = new EventHandler* [GetMaxFds()]; diff --git a/src/socketengines/socketengine_kqueue.cpp b/src/socketengines/socketengine_kqueue.cpp index a6c84133a..99ac51499 100644 --- a/src/socketengines/socketengine_kqueue.cpp +++ b/src/socketengines/socketengine_kqueue.cpp @@ -74,7 +74,7 @@ KQueueEngine::KQueueEngine() { 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->Exit(EXIT_STATUS_SOCKETENGINE); + ServerInstance->QuickExit(EXIT_STATUS_SOCKETENGINE); } this->RecoverFromFork(); @@ -97,7 +97,7 @@ void KQueueEngine::RecoverFromFork() ServerInstance->Logs->Log("SOCKET", LOG_DEFAULT, "ERROR: this is a fatal error, exiting now."); std::cout << "ERROR: Could not initialize socket engine. Your kernel probably does not have the proper features." << std::endl; std::cout << "ERROR: this is a fatal error, exiting now." << std::endl; - ServerInstance->Exit(EXIT_STATUS_SOCKETENGINE); + ServerInstance->QuickExit(EXIT_STATUS_SOCKETENGINE); } CurrentSetSize = 0; } diff --git a/src/socketengines/socketengine_poll.cpp b/src/socketengines/socketengine_poll.cpp index 37f4b6836..493b22630 100644 --- a/src/socketengines/socketengine_poll.cpp +++ b/src/socketengines/socketengine_poll.cpp @@ -32,15 +32,15 @@ #include "socketengine.h" #ifndef _WIN32 - #ifndef __USE_XOPEN - #define __USE_XOPEN /* fuck every fucking OS ever made. needed by poll.h to work.*/ - #endif - #include <poll.h> - #include <sys/poll.h> +# ifndef __USE_XOPEN +# define __USE_XOPEN /* fuck every fucking OS ever made. needed by poll.h to work.*/ +# endif +# include <poll.h> +# include <sys/poll.h> +# include <sys/resource.h> #else - /* *grumble* */ - #define struct pollfd WSAPOLLFD - #define poll WSAPoll +# define struct pollfd WSAPOLLFD +# define poll WSAPoll #endif class InspIRCd; @@ -73,40 +73,20 @@ public: #endif -#ifdef BSD - #include <sys/sysctl.h> -#else - #include <ulimit.h> -#endif - PollEngine::PollEngine() { CurrentSetSize = 0; -#ifdef BSD - int mib[2]; - size_t len; - - mib[0] = CTL_KERN; -#ifdef KERN_MAXFILESPERPROC - mib[1] = KERN_MAXFILESPERPROC; -#else - mib[1] = KERN_MAXFILES; -#endif - len = sizeof(MAX_DESCRIPTORS); - sysctl(mib, 2, &MAX_DESCRIPTORS, &len, NULL, 0); -#else - int max = ulimit(4, 0); - if (max > 0) + struct rlimit limits; + if (!getrlimit(RLIMIT_NOFILE, &limits)) { - MAX_DESCRIPTORS = max; + MAX_DESCRIPTORS = limits.rlim_cur; } 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->Exit(EXIT_STATUS_SOCKETENGINE); + ServerInstance->QuickExit(EXIT_STATUS_SOCKETENGINE); } -#endif ref = new EventHandler* [GetMaxFds()]; events = new struct pollfd[GetMaxFds()]; diff --git a/src/socketengines/socketengine_ports.cpp b/src/socketengines/socketengine_ports.cpp index 8a2fb87f4..ba4e8f2d7 100644 --- a/src/socketengines/socketengine_ports.cpp +++ b/src/socketengines/socketengine_ports.cpp @@ -76,7 +76,7 @@ PortsEngine::PortsEngine() { 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->Exit(EXIT_STATUS_SOCKETENGINE); + ServerInstance->QuickExit(EXIT_STATUS_SOCKETENGINE); } EngineHandle = port_create(); @@ -86,7 +86,7 @@ PortsEngine::PortsEngine() ServerInstance->Logs->Log("SOCKET", LOG_SPARSE, "ERROR: This is a fatal error, exiting now."); std::cout << "ERROR: Could not initialize socket engine: " << strerror(errno) << std::endl; std::cout << "ERROR: This is a fatal error, exiting now." << std::endl; - ServerInstance->Exit(EXIT_STATUS_SOCKETENGINE); + ServerInstance->QuickExit(EXIT_STATUS_SOCKETENGINE); } CurrentSetSize = 0; diff --git a/src/socketengines/socketengine_select.cpp b/src/socketengines/socketengine_select.cpp index de366266f..f995b5472 100644 --- a/src/socketengines/socketengine_select.cpp +++ b/src/socketengines/socketengine_select.cpp @@ -177,7 +177,9 @@ int SelectEngine::DispatchEvents() if (has_write) { WriteEvents++; - SetEventMask(ev, ev->GetEventMask() & ~(FD_WRITE_WILL_BLOCK | FD_WANT_SINGLE_WRITE)); + int newmask = (ev->GetEventMask() & ~(FD_WRITE_WILL_BLOCK | FD_WANT_SINGLE_WRITE)); + this->OnSetEvent(ev, ev->GetEventMask(), newmask); + SetEventMask(ev, newmask); ev->HandleEvent(EVENT_WRITE); } } |