From 8399a0bede79afd8f8a7cb23a4ded974584d437a Mon Sep 17 00:00:00 2001 From: brain Date: Mon, 9 May 2005 20:56:44 +0000 Subject: Basics of kqueue() implementation for socket engine git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@1348 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/commands.cpp | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'src/commands.cpp') diff --git a/src/commands.cpp b/src/commands.cpp index 315caf9b9..f98ad5eb2 100644 --- a/src/commands.cpp +++ b/src/commands.cpp @@ -23,6 +23,11 @@ #include #include #include +#ifdef USE_KQUEUE +#include +#include +#include +#endif #include #include #include @@ -68,6 +73,10 @@ using namespace std; +#ifdef USE_KQUEUE +extern int kq; +#endif + extern int MODCOUNT; extern std::vector modules; extern std::vector factory; @@ -960,8 +969,17 @@ void handle_quit(char **parameters, int pcnt, userrec *user) /* push the socket on a stack of sockets due to be closed at the next opportunity */ if (user->fd > -1) { - shutdown(user->fd,2); - close(user->fd); +#ifdef USE_KQUEUE + struct kevent ke; + EV_SET(&ke, user->fd, EVFILT_READ, EV_DELETE, 0, 0, NULL); + int i = kevent(kq, &ke, 1, 0, 0, NULL); + if (i == -1) + { + log(DEBUG,"kqueue: Failed to remove user from queue!"); + } +#endif + shutdown(user->fd,2); + close(user->fd); } if (iter != clientlist.end()) -- cgit v1.2.3