]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/socketengine_ports.cpp
Remove the last uses of localised fake clients. This removes a lot of allocations...
[user/henk/code/inspircd.git] / src / socketengine_ports.cpp
index f036a8e10ef1c03c4196ce6088148ca05c881e2e..352b730620fbc7d300eaadbe9e16eeffaef4189c 100644 (file)
@@ -13,7 +13,7 @@
 
 #include "inspircd.h"
 #include "exitcodes.h"
-#include <sys/epoll.h>
+#include <port.h>
 #include "socketengine_ports.h"
 
 PortsEngine::PortsEngine(InspIRCd* Instance) : SocketEngine(Instance)
@@ -26,14 +26,14 @@ PortsEngine::PortsEngine(InspIRCd* Instance) : SocketEngine(Instance)
                ServerInstance->Log(SPARSE,"ERROR: This is a fatal error, exiting now.");
                printf("ERROR: Could not initialize socket engine: %s\n", strerror(errno));
                printf("ERROR: This is a fatal error, exiting now.\n");
-               InspIRCd::Exit(EXIT_STATUS_SOCKETENGINE);
+               ServerInstance->Exit(EXIT_STATUS_SOCKETENGINE);
        }
        CurrentSetSize = 0;
 }
 
 PortsEngine::~PortsEngine()
 {
-       close(EngineHandle);
+       this->Close(EngineHandle);
 }
 
 bool PortsEngine::AddFd(EventHandler* eh)
@@ -104,10 +104,17 @@ int PortsEngine::DispatchEvents()
        {
                switch (this->events[i].portev_source)
                {
-               case PORT_SOURCE_FD:
-                       int fd = this->events[i].portev_object;
-                       ref[fd]->HandleEvent((this->events[i].portev_events & POLLRDNORM) ? EVENT_READ : EVENT_WRITE);
-               default:
+                       case PORT_SOURCE_FD:
+                       {
+                               int fd = this->events[i].portev_object;
+                               if (ref[fd])
+                               {
+                                       // reinsert port for next time around
+                                       port_associate(EngineHandle, PORT_SOURCE_FD, fd, POLLRDNORM, ref[fd]);
+                                       ref[fd]->HandleEvent((this->events[i].portev_events & POLLRDNORM) ? EVENT_READ : EVENT_WRITE);
+                               }
+                       }
+                       default:
                        break;
                }
        }