diff options
author | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-09-26 01:43:09 +0000 |
---|---|---|
committer | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2009-09-26 01:43:09 +0000 |
commit | 939cb0ba987f927f1ad900d45f98ba6d8e03e9d4 (patch) | |
tree | f35510ff56e01ece2a0417c9a6fbad17fb7acfee /src/socketengines/socketengine_iocp.cpp | |
parent | c8026bc2d73344e1df526f0a80694046efa4b22a (diff) |
Clean up SocketEngine interface to allow edge-triggered I/O and sockets that do not force readability.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11760 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/socketengines/socketengine_iocp.cpp')
-rw-r--r-- | src/socketengines/socketengine_iocp.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/socketengines/socketengine_iocp.cpp b/src/socketengines/socketengine_iocp.cpp index 3c3181909..e09fb4d0a 100644 --- a/src/socketengines/socketengine_iocp.cpp +++ b/src/socketengines/socketengine_iocp.cpp @@ -33,7 +33,6 @@ IOCPEngine::IOCPEngine() /* Null variables out. */ CurrentSetSize = 0; - EngineHandle = 0; MAX_DESCRIPTORS = 10240; ref = new EventHandler* [10240]; memset(ref, 0, sizeof(EventHandler*) * MAX_DESCRIPTORS); @@ -47,7 +46,7 @@ IOCPEngine::~IOCPEngine() delete[] ref; } -bool IOCPEngine::AddFd(EventHandler* eh, bool writeFirst) +bool IOCPEngine::AddFd(EventHandler* eh, int event_mask) { /* Does it at least look valid? */ if (!eh) @@ -92,7 +91,7 @@ bool IOCPEngine::AddFd(EventHandler* eh, bool writeFirst) ServerInstance->Logs->Log("SOCKET",DEBUG, "New fake fd: %u, real fd: %u, address 0x%p", *fake_fd, eh->GetFd(), eh); /* post a write event if there is data to be written */ - if(writeFirst) + if (event_mask & (FD_WANT_POLL_WRITE | FD_WANT_FAST_WRITE)) WantWrite(eh); /* we're all good =) */ @@ -107,6 +106,7 @@ bool IOCPEngine::AddFd(EventHandler* eh, bool writeFirst) } ++CurrentSetSize; + SocketEngine::SetEventMask(eh, event_mask); ref[*fake_fd] = eh; return true; @@ -171,7 +171,7 @@ bool IOCPEngine::DelFd(EventHandler* eh, bool force /* = false */) return true; } -void IOCPEngine::WantWrite(EventHandler* eh) +void IOCPEngine::OnSetEvent(EventHandler* eh, int old_mask, int new_mask) { if (!eh) return; @@ -183,7 +183,7 @@ void IOCPEngine::WantWrite(EventHandler* eh) return; /* Post event - write begin */ - if(!eh->GetExt("windows_writeevent", m_writeEvent)) + if((new_mask & (FD_WANT_POLL_WRITE | FD_WANT_FAST_WRITE)) && !eh->GetExt("windows_writeevent", m_writeEvent)) { ULONG_PTR completion_key = (ULONG_PTR)*fake_fd; Overlapped * ov = new Overlapped(SOCKET_IO_EVENT_WRITE_READY, 0); @@ -315,6 +315,7 @@ int IOCPEngine::DispatchEvents() { WriteEvents++; eh->Shrink("windows_writeevent"); + SetEventMask(eh, eh->GetEventMask() & ~FD_WRITE_WILL_BLOCK); eh->HandleEvent(EVENT_WRITE, 0); } break; @@ -322,6 +323,7 @@ int IOCPEngine::DispatchEvents() case SOCKET_IO_EVENT_READ_READY: { ReadEvents++; + SetEventMask(eh, eh->GetEventMask() & ~FD_READ_WILL_BLOCK); if(ov->m_params) { // if we had params, it means we are a udp socket with a udp_overlap pointer in this long. |