#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.
#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
*/
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);
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);
return (int)i;
}
-std::string PortsEngine::GetName()
-{
- return "ports";
-}
-
SocketEngine* CreateSocketEngine()
{
return new PortsEngine;