From 810c662c9b55908101ca085293c52c3239ef22d1 Mon Sep 17 00:00:00 2001 From: danieldg Date: Sat, 26 Sep 2009 14:12:45 +0000 Subject: Add FD_WANT_SINGLE_WRITE to efficiently replace FD_WANT_POLL_WRITE git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@11762 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/socketengines/socketengine_epoll.cpp | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'src/socketengines/socketengine_epoll.cpp') diff --git a/src/socketengines/socketengine_epoll.cpp b/src/socketengines/socketengine_epoll.cpp index 672ff4a7b..059798d25 100644 --- a/src/socketengines/socketengine_epoll.cpp +++ b/src/socketengines/socketengine_epoll.cpp @@ -58,12 +58,12 @@ EPollEngine::~EPollEngine() static int mask_to_epoll(int event_mask) { int rv = 0; - if (event_mask & (FD_WANT_POLL_READ | FD_WANT_POLL_WRITE)) + if (event_mask & (FD_WANT_POLL_READ | FD_WANT_POLL_WRITE | FD_WANT_SINGLE_WRITE)) { // we need to use standard polling on this FD if (event_mask & (FD_WANT_POLL_READ | FD_WANT_FAST_READ)) rv |= EPOLLIN; - if (event_mask & (FD_WANT_POLL_WRITE | FD_WANT_FAST_WRITE)) + if (event_mask & (FD_WANT_POLL_WRITE | FD_WANT_FAST_WRITE | FD_WANT_SINGLE_WRITE)) rv |= EPOLLOUT; } else @@ -182,16 +182,28 @@ int EPollEngine::DispatchEvents() eh->HandleEvent(EVENT_ERROR, errcode); continue; } + int mask = eh->GetEventMask(); + if (events[j].events & EPOLLIN) + mask &= ~FD_READ_WILL_BLOCK; + if (events[j].events & EPOLLOUT) + { + mask &= ~FD_WRITE_WILL_BLOCK; + if (mask & FD_WANT_SINGLE_WRITE) + { + int nm = mask & ~FD_WANT_SINGLE_WRITE; + OnSetEvent(eh, mask, nm); + mask = nm; + } + } + SetEventMask(eh, mask); if (events[j].events & EPOLLIN) { ReadEvents++; - SetEventMask(eh, eh->GetEventMask() & ~FD_READ_WILL_BLOCK); eh->HandleEvent(EVENT_READ); } if (events[j].events & EPOLLOUT) { WriteEvents++; - SetEventMask(eh, eh->GetEventMask() & ~FD_WRITE_WILL_BLOCK); eh->HandleEvent(EVENT_WRITE); } } -- cgit v1.2.3