diff options
Diffstat (limited to 'src/socketengines/socketengine_epoll.cpp')
-rw-r--r-- | src/socketengines/socketengine_epoll.cpp | 26 |
1 files changed, 12 insertions, 14 deletions
diff --git a/src/socketengines/socketengine_epoll.cpp b/src/socketengines/socketengine_epoll.cpp index 7d919ec9f..c442e340d 100644 --- a/src/socketengines/socketengine_epoll.cpp +++ b/src/socketengines/socketengine_epoll.cpp @@ -18,16 +18,12 @@ */ -#include <vector> -#include <string> -#include <map> #include "inspircd.h" #include "exitcodes.h" -#include "socketengine.h" + #include <sys/epoll.h> -#include <ulimit.h> +#include <sys/resource.h> #include <iostream> -#define EP_DELAY 5 /** A specialisation of the SocketEngine class, designed to use linux 2.6 epoll(). */ @@ -42,8 +38,12 @@ namespace void SocketEngine::Init() { - // MAX_DESCRIPTORS is mainly used for display purposes, no problem if ulimit() fails and returns a negative number - MAX_DESCRIPTORS = ulimit(4, 0); + // MAX_DESCRIPTORS is mainly used for display purposes, no problem if getrlimit() fails + struct rlimit limit; + if (!getrlimit(RLIMIT_NOFILE, &limit)) + { + MAX_DESCRIPTORS = limit.rlim_cur; + } // 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. @@ -185,7 +185,7 @@ int SocketEngine::DispatchEvents() if (ev.events & EPOLLHUP) { stats.ErrorEvents++; - eh->HandleEvent(EVENT_ERROR, 0); + eh->OnEventHandlerError(0); continue; } @@ -197,7 +197,7 @@ int SocketEngine::DispatchEvents() int errcode; if (getsockopt(fd, SOL_SOCKET, SO_ERROR, &errcode, &codesize) < 0) errcode = errno; - eh->HandleEvent(EVENT_ERROR, errcode); + eh->OnEventHandlerError(errcode); continue; } @@ -217,16 +217,14 @@ int SocketEngine::DispatchEvents() eh->SetEventMask(mask); if (ev.events & EPOLLIN) { - stats.ReadEvents++; - eh->HandleEvent(EVENT_READ); + eh->OnEventHandlerRead(); if (eh != GetRef(fd)) // whoa! we got deleted, better not give out the write event continue; } if (ev.events & EPOLLOUT) { - stats.WriteEvents++; - eh->HandleEvent(EVENT_WRITE); + eh->OnEventHandlerWrite(); } } |