]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/socketengines/socketengine_kqueue.cpp
Add ConfigTag::getUInt for reading unsigned config values.
[user/henk/code/inspircd.git] / src / socketengines / socketengine_kqueue.cpp
index 922cb7f2d99d6df40afdf9ec3b76e0a19019764f..b23cfbd9dcf2b6af86a415bac1c9132d7c4ac92a 100644 (file)
 
 
 #include "inspircd.h"
-#include "exitcodes.h"
+
 #include <sys/types.h>
 #include <sys/event.h>
 #include <sys/time.h>
-#include <iostream>
 #include <sys/sysctl.h>
 
 /** A specialisation of the SocketEngine class, designed to use BSD kqueue().
@@ -46,20 +45,7 @@ namespace
  */
 void SocketEngine::Init()
 {
-       MAX_DESCRIPTORS = 0;
-       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);
-       // MAX_DESCRIPTORS is mainly used for display purposes, no problem if the sysctl() below fails
-       sysctl(mib, 2, &MAX_DESCRIPTORS, &len, NULL, 0);
-
+       LookupMaxFds();
        RecoverFromFork();
 }
 
@@ -72,13 +58,7 @@ void SocketEngine::RecoverFromFork()
         */
        EngineHandle = kqueue();
        if (EngineHandle == -1)
-       {
-               ServerInstance->Logs->Log("SOCKET", LOG_DEFAULT, "ERROR: Could not initialize socket engine. Your kernel probably does not have the proper features.");
-               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->QuickExit(EXIT_STATUS_SOCKETENGINE);
-       }
+               InitError();
 }
 
 /** Shutdown the kqueue engine
@@ -199,7 +179,6 @@ int SocketEngine::DispatchEvents()
                }
                if (filter == EVFILT_WRITE)
                {
-                       stats.WriteEvents++;
                        /* When mask is FD_WANT_FAST_WRITE or FD_WANT_SINGLE_WRITE,
                         * we set a one-shot write, so we need to clear that bit
                         * to detect when it set again.
@@ -210,7 +189,6 @@ int SocketEngine::DispatchEvents()
                }
                else if (filter == EVFILT_READ)
                {
-                       stats.ReadEvents++;
                        eh->SetEventMask(eh->GetEventMask() & ~FD_READ_WILL_BLOCK);
                        eh->OnEventHandlerRead();
                }