]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/socketengines/socketengine_epoll.cpp
Don't update the idle timer when a user replies to a CTCP.
[user/henk/code/inspircd.git] / src / socketengines / socketengine_epoll.cpp
index 29404f416f9bcdd5eca94caaf1b4bd8dab99f910..60b365ee139027a8cd75482157c7e7a8db9536f4 100644 (file)
 
 
 #include "inspircd.h"
-#include "exitcodes.h"
 
 #include <sys/epoll.h>
-#include <ulimit.h>
-#include <iostream>
-#define EP_DELAY 5
+#include <sys/resource.h>
 
 /** A specialisation of the SocketEngine class, designed to use linux 2.6 epoll().
  */
@@ -39,21 +36,13 @@ 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);
+       LookupMaxFds();
 
        // 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.
        EngineHandle = epoll_create(128);
-
        if (EngineHandle == -1)
-       {
-               ServerInstance->Logs->Log("SOCKET", LOG_DEFAULT, "ERROR: Could not initialize socket engine: %s", strerror(errno));
-               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->QuickExit(EXIT_STATUS_SOCKETENGINE);
-       }
+               InitError();
 }
 
 void SocketEngine::RecoverFromFork()
@@ -182,7 +171,7 @@ int SocketEngine::DispatchEvents()
                if (ev.events & EPOLLHUP)
                {
                        stats.ErrorEvents++;
-                       eh->HandleEvent(EVENT_ERROR, 0);
+                       eh->OnEventHandlerError(0);
                        continue;
                }
 
@@ -194,7 +183,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;
                }
 
@@ -214,16 +203,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();
                }
        }