diff options
-rw-r--r-- | src/socketengine_epoll.cpp | 8 | ||||
-rw-r--r-- | src/socketengine_kqueue.cpp | 9 | ||||
-rw-r--r-- | src/socketengine_select.cpp | 6 |
3 files changed, 8 insertions, 15 deletions
diff --git a/src/socketengine_epoll.cpp b/src/socketengine_epoll.cpp index cbf800a5c..c3c0c89a2 100644 --- a/src/socketengine_epoll.cpp +++ b/src/socketengine_epoll.cpp @@ -79,6 +79,9 @@ bool EPollEngine::AddFd(EventHandler* eh) void EPollEngine::WantWrite(EventHandler* eh) { + /** Use oneshot so that the system removes the writeable + * status for us and saves us a call. + */ struct epoll_event ev; ev.events = EPOLLOUT | EPOLLONESHOT; ev.data.fd = eh->GetFd(); @@ -87,10 +90,6 @@ void EPollEngine::WantWrite(EventHandler* eh) { ServerInstance->Log(DEBUG,"epoll: Could not set want write on fd %d!",eh->GetFd()); } - else - { - ServerInstance->Log(DEBUG,"epoll: WantWrite set on %d",eh->GetFd()); - } } bool EPollEngine::DelFd(EventHandler* eh) @@ -137,7 +136,6 @@ int EPollEngine::DispatchEvents() ServerInstance->Log(DEBUG,"Handle %s event on fd %d",events[j].events & EPOLLOUT ? "write" : "read", events[j].data.fd); if (events[j].events & EPOLLOUT) { - ServerInstance->Log(DEBUG,"One shot, we should EPOLL_CTL_MOD here to set it read only."); struct epoll_event ev; ev.events = EPOLLIN; ev.data.fd = events[j].data.fd; diff --git a/src/socketengine_kqueue.cpp b/src/socketengine_kqueue.cpp index e0e6fe029..4e5679c77 100644 --- a/src/socketengine_kqueue.cpp +++ b/src/socketengine_kqueue.cpp @@ -109,6 +109,10 @@ bool KQueueEngine::DelFd(EventHandler* eh) void KQueueEngine::WantWrite(EventHandler* eh) { + /** When changing an item in a kqueue, there is no 'modify' call + * as in epoll. Instead, we add the item again, and this overwrites + * the original setting rather than adding it twice. See man kqueue. + */ struct kevent ke; EV_SET(&ke, eh->GetFd(), EVFILT_WRITE, EV_ADD | EV_ONESHOT, 0, 0, NULL); int i = kevent(EngineHandle, &ke, 1, 0, 0, NULL); @@ -116,10 +120,6 @@ void KQueueEngine::WantWrite(EventHandler* eh) { ServerInstance->Log(DEBUG,"kqueue: Unable to set fd %d for wanting write", eh->GetFd()); } - else - { - ServerInstance->Log(DEBUG,"kqueue: Set fd %d for want write", eh->GetFd()); - } } int KQueueEngine::GetMaxFds() @@ -142,7 +142,6 @@ int KQueueEngine::DispatchEvents() ServerInstance->Log(DEBUG,"Handle %s event on fd %d",ke_list[j].flags & EVFILT_WRITE ? "write" : "read", ke_list[j].ident); if (ke_list[j].flags & EVFILT_WRITE) { - ServerInstance->Log(DEBUG,"kqueue: Write socket wants to be set back to read"); struct kevent ke; EV_SET(&ke, ke_list[j].ident, EVFILT_READ, EV_ADD, 0, 0, NULL); int i = kevent(EngineHandle, &ke, 1, 0, 0, NULL); diff --git a/src/socketengine_select.cpp b/src/socketengine_select.cpp index 7a21fab84..8b0379152 100644 --- a/src/socketengine_select.cpp +++ b/src/socketengine_select.cpp @@ -60,11 +60,7 @@ bool SelectEngine::AddFd(EventHandler* eh) void SelectEngine::WantWrite(EventHandler* eh) { - int fd = eh->GetFd(); - - writeable[fd] = true; - - ServerInstance->Log(DEBUG,"Set %d to writeable", fd); + writeable[eh->GetFd()] = true; } bool SelectEngine::DelFd(EventHandler* eh) |