From 457e12e54100eaff493595d5042fa85f00d261c5 Mon Sep 17 00:00:00 2001 From: brain Date: Fri, 6 Oct 2006 19:59:09 +0000 Subject: Make the socketengines always clear the slots on DelFd, even if the underlying queue call fails git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5437 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/socketengine_epoll.cpp | 6 ++++-- src/socketengine_kqueue.cpp | 7 +++++-- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/socketengine_epoll.cpp b/src/socketengine_epoll.cpp index 9cc5f90f0..7d35997c5 100644 --- a/src/socketengine_epoll.cpp +++ b/src/socketengine_epoll.cpp @@ -90,14 +90,16 @@ bool EPollEngine::DelFd(EventHandler* eh) eh->Readable() ? ev.events = EPOLLIN : ev.events = EPOLLOUT; ev.data.fd = fd; int i = epoll_ctl(EngineHandle, EPOLL_CTL_DEL, fd, &ev); + + CurrentSetSize--; + ref[fd] = NULL; + if (i < 0) { ServerInstance->Log(DEBUG,"epoll: List deletion failure: %s",strerror(errno)); return false; } - CurrentSetSize--; - ref[fd] = NULL; return true; } diff --git a/src/socketengine_kqueue.cpp b/src/socketengine_kqueue.cpp index 662be649a..15d0e30bc 100644 --- a/src/socketengine_kqueue.cpp +++ b/src/socketengine_kqueue.cpp @@ -70,6 +70,7 @@ bool KQueueEngine::AddFd(EventHandler* eh) struct kevent ke; ServerInstance->Log(DEBUG,"kqueue: Add socket to events, kq=%d socket=%d",EngineHandle,fd); EV_SET(&ke, fd, eh->Readable() ? EVFILT_READ : EVFILT_WRITE, EV_ADD, 0, 0, NULL); + int i = kevent(EngineHandle, &ke, 1, 0, 0, NULL); if (i == -1) { @@ -92,6 +93,10 @@ bool KQueueEngine::DelFd(EventHandler* eh) struct kevent ke; EV_SET(&ke, fd, eh->Readable() ? EVFILT_READ : EVFILT_WRITE, EV_DELETE, 0, 0, NULL); + + CurrentSetSize--; + ref[fd] = NULL; + int i = kevent(EngineHandle, &ke, 1, 0, 0, NULL); if (i == -1) { @@ -99,8 +104,6 @@ bool KQueueEngine::DelFd(EventHandler* eh) return false; } - CurrentSetSize--; - ref[fd] = NULL; return true; } -- cgit v1.2.3