]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/socketengines/socketengine_ports.cpp
Replace SocketEngine::GetName() with INSPIRCD_SOCKETENGINE_NAME define
[user/henk/code/inspircd.git] / src / socketengines / socketengine_ports.cpp
index 936a8f6b96c28028861f9cc0d83f1992ff4de0bc..74c36712bad0213e786288a68a79c55c593fb414 100644 (file)
 
 #include "inspircd.h"
 #include "exitcodes.h"
-#include <port.h>
-
-#ifndef SOCKETENGINE_PORTS
-#define SOCKETENGINE_PORTS
 
 #ifndef __sun
 # error You need Solaris 10 or later to make use of this code.
@@ -36,6 +32,7 @@
 #include "socketengine.h"
 #include <port.h>
 #include <iostream>
+#include <ulimit.h>
 
 /** A specialisation of the SocketEngine class, designed to use solaris 10 I/O completion ports
  */
@@ -57,14 +54,8 @@ public:
        virtual void OnSetEvent(EventHandler* eh, int old_mask, int new_mask);
        virtual void DelFd(EventHandler* eh);
        virtual int DispatchEvents();
-       virtual std::string GetName();
 };
 
-#endif
-
-
-#include <ulimit.h>
-
 PortsEngine::PortsEngine() : events(1)
 {
        int max = ulimit(4, 0);
@@ -170,27 +161,29 @@ int PortsEngine::DispatchEvents()
                if (ev.portev_source != PORT_SOURCE_FD)
                        continue;
 
-               int fd = ev.portev_object;
+               // Copy these in case the vector gets resized and ev invalidated
+               const int fd = ev.portev_object;
+               const int portev_events = ev.portev_events;
                EventHandler* eh = GetRef(fd);
                if (!eh)
                        continue;
 
                int mask = eh->GetEventMask();
-               if (ev.portev_events & POLLWRNORM)
+               if (portev_events & POLLWRNORM)
                        mask &= ~(FD_WRITE_WILL_BLOCK | FD_WANT_FAST_WRITE | FD_WANT_SINGLE_WRITE);
-               if (ev.portev_events & POLLRDNORM)
+               if (portev_events & POLLRDNORM)
                        mask &= ~FD_READ_WILL_BLOCK;
                // reinsert port for next time around, pretending to be one-shot for writes
                SetEventMask(eh, mask);
                port_associate(EngineHandle, PORT_SOURCE_FD, fd, mask_to_events(mask), eh);
-               if (ev.portev_events & POLLRDNORM)
+               if (portev_events & POLLRDNORM)
                {
                        ReadEvents++;
                        eh->HandleEvent(EVENT_READ);
                        if (eh != GetRef(fd))
                                continue;
                }
-               if (ev.portev_events & POLLWRNORM)
+               if (portev_events & POLLWRNORM)
                {
                        WriteEvents++;
                        eh->HandleEvent(EVENT_WRITE);
@@ -200,11 +193,6 @@ int PortsEngine::DispatchEvents()
        return (int)i;
 }
 
-std::string PortsEngine::GetName()
-{
-       return "ports";
-}
-
 SocketEngine* CreateSocketEngine()
 {
        return new PortsEngine;