From 61fed23a3e9a62f19c2f88208585b31356c986ef Mon Sep 17 00:00:00 2001 From: w00t Date: Sun, 7 Sep 2008 18:31:21 +0000 Subject: Start moving IO hooking from being bufferedsocket based to residing in EventHandler, this will pave the way for a generic listener type, and also simplifies a lot of code. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@10447 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/configreader.cpp | 31 ------------------------------- src/socketengine.cpp | 21 +++++++++++++++++++++ 2 files changed, 21 insertions(+), 31 deletions(-) (limited to 'src') diff --git a/src/configreader.cpp b/src/configreader.cpp index 1e8e0a7e9..cce362ed2 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -65,37 +65,6 @@ void ServerConfig::ClearStack() include_stack.clear(); } -Module* ServerConfig::GetIOHook(BufferedSocket* is) -{ - std::map::iterator x = SocketIOHookModule.find(is); - return (x != SocketIOHookModule.end() ? x->second : NULL); -} - -bool ServerConfig::AddIOHook(Module* iomod, BufferedSocket* is) -{ - if (!GetIOHook(is)) - { - SocketIOHookModule[is] = iomod; - is->IsIOHooked = true; - return true; - } - else - { - throw ModuleException("BufferedSocket derived class already hooked by another module"); - } -} - -bool ServerConfig::DelIOHook(BufferedSocket* is) -{ - std::map::iterator x = SocketIOHookModule.find(is); - if (x != SocketIOHookModule.end()) - { - SocketIOHookModule.erase(x); - return true; - } - return false; -} - void ServerConfig::Update005() { std::stringstream out(data005); diff --git a/src/socketengine.cpp b/src/socketengine.cpp index c7188b55a..74f8c1861 100644 --- a/src/socketengine.cpp +++ b/src/socketengine.cpp @@ -41,6 +41,27 @@ #include "inspircd.h" #include "socketengine.h" +bool EventHandler::AddIOHook(Module *IOHooker) +{ + if (this->IOHook) + return false; + + this->IOHook = IOHooker; +} + +bool EventHandler::DelIOHook() +{ + if (!this->IOHook) + return false + + this->IOHook = false; +} + +Module *EventHandler::GetIOHook() +{ + return this->IOHook; +} + int EventHandler::GetFd() { return this->fd; -- cgit v1.2.3