]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/socketengine_kqueue.cpp
Add sanity checks to the ssl modules so that theres no possibility of an out of range...
[user/henk/code/inspircd.git] / src / socketengine_kqueue.cpp
index 7fcdae2b6a58084056cb25268e9b2e1365fb253a..50f6242e2914de027b92d613e5c2fd2ec970e54e 100644 (file)
 
 KQueueEngine::KQueueEngine(InspIRCd* Instance) : SocketEngine(Instance)
 {
+       this->RecoverFromFork();
+}
+
+void KQueueEngine::RecoverFromFork()
+{
+       /*
+        * The only bad thing about kqueue is that its fd cant survive a fork and is not inherited.
+        * BUM HATS.
+        * 
+        */
        EngineHandle = kqueue();
        if (EngineHandle == -1)
        {
@@ -28,14 +38,14 @@ KQueueEngine::KQueueEngine(InspIRCd* Instance) : SocketEngine(Instance)
                ServerInstance->Log(SPARSE,"ERROR: this is a fatal error, exiting now.");
                printf("ERROR: Could not initialize socket engine. Your kernel probably does not have the proper features.");
                printf("ERROR: this is a fatal error, exiting now.");
-               InspIRCd::Exit(EXIT_STATUS_SOCKETENGINE);
+               ServerInstance->Exit(EXIT_STATUS_SOCKETENGINE);
        }
        CurrentSetSize = 0;
 }
 
 KQueueEngine::~KQueueEngine()
 {
-       close(EngineHandle);
+       this->Close(EngineHandle);
 }
 
 bool KQueueEngine::AddFd(EventHandler* eh)
@@ -51,15 +61,16 @@ bool KQueueEngine::AddFd(EventHandler* eh)
        if (ref[fd])
                return false;
 
-       ref[fd] = eh;
-
        struct kevent ke;
        EV_SET(&ke, fd, eh->Readable() ? EVFILT_READ : EVFILT_WRITE, EV_ADD, 0, 0, NULL);
 
        int i = kevent(EngineHandle, &ke, 1, 0, 0, NULL);
        if (i == -1)
+       {
                return false;
+       }
 
+       ref[fd] = eh;
        CurrentSetSize++;
 
        ServerInstance->Log(DEBUG,"New file descriptor: %d", fd);