]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Start moving IO hooking from being bufferedsocket based to residing in EventHandler...
authorw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>
Sun, 7 Sep 2008 18:31:21 +0000 (18:31 +0000)
committerw00t <w00t@e03df62e-2008-0410-955e-edbf42e46eb7>
Sun, 7 Sep 2008 18:31:21 +0000 (18:31 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@10447 e03df62e-2008-0410-955e-edbf42e46eb7

include/configreader.h
include/socket.h
include/socketengine.h
src/configreader.cpp
src/socketengine.cpp

index 5e437d153b759bf135782e4d06dac882f523646e..af9c33533b02649c64065d4d4cd5b6d973aeb0d4 100644 (file)
@@ -607,10 +607,6 @@ class CoreExport ServerConfig : public Extensible
         */
        std::vector<ListenSocket*> ports;
 
-       /** socket objects that are attached to by modules
-        */
-       std::map<BufferedSocket*, Module*> SocketIOHookModule;
-
        /** The 005 tokens of this server (ISUPPORT)
         * populated/repopulated upon loading or unloading
         * modules.
@@ -823,26 +819,6 @@ class CoreExport ServerConfig : public Extensible
 
        void ValidateNoSpaces(const char* p, const std::string &tag, const std::string &val);
 
-       /** Get a pointer to the module which has hooked the given BufferedSocket class.
-        * @parameter port Port number
-        * @return Returns a pointer to the hooking module, or NULL
-        */
-       Module* GetIOHook(BufferedSocket* is);
-
-       /** Hook a module to an BufferedSocket class, so that it can receive notifications
-        * of low-level socket activity.
-        * @param iomod The module to hook to the socket
-        * @param is The BufferedSocket to attach to
-        * @return True if the hook was successful.
-        */
-       bool AddIOHook(Module* iomod, BufferedSocket* is);
-
-       /** Delete a module hook from an BufferedSocket.
-        * @param is The BufferedSocket to detatch from.
-        * @return True if the unhook was successful
-        */
-       bool DelIOHook(BufferedSocket* is);
-
        /** Returns the fully qualified path to the inspircd directory
         * @return The full program directory
         */
index a26c1256d2db4f2967aa209dc442ed4827acf3cf..105984f7483f4209413407925e585455e0510989 100644 (file)
@@ -139,6 +139,8 @@ namespace irc
        }
 }
 
+
+
 /** This class handles incoming connections on client ports.
  * It will create a new User for every valid connection
  * and assign it a file descriptor.
index f16ec3fea045272c8ef99e64c6b261f77f0ba867..127a2fd902f12f77e556eafa8eb3fdbc7797af83 100644 (file)
@@ -68,8 +68,28 @@ class CoreExport EventHandler : public Extensible
         * other forms of IPC.
         */
        int fd;
+
+       /** Pointer to the module which has hooked the given EventHandler for IO events.
+        */
+       Module *IOHook;
  public:
 
+       /** Return the current hooker of IO events for this socket, or NULL.
+        * @return Hooker module, if set, or NULL.
+        */
+       Module *GetIOHook();
+
+       /** Set a module as hooking IO events on this socket.
+        * @param IOHooker The module hooking IO
+        * @return True if the hook could be added, false otherwise.
+        */
+       bool AddIOHook(Module *IOHooker);
+
+       /** Remove IO hooking from a module
+        * @return True if hooking was successfully removed, false otherwise.
+        */
+       bool DelIOHook();
+
        /** Get the current file descriptor
         * @return The file descriptor of this handler
         */
index 1e8e0a7e9d22ac4aa2d084d9dcda263fa5f2e76f..cce362ed2553e03eabd03ad61bafc57cbf5cd444 100644 (file)
@@ -65,37 +65,6 @@ void ServerConfig::ClearStack()
        include_stack.clear();
 }
 
-Module* ServerConfig::GetIOHook(BufferedSocket* is)
-{
-       std::map<BufferedSocket*,Module*>::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<BufferedSocket*,Module*>::iterator x = SocketIOHookModule.find(is);
-       if (x != SocketIOHookModule.end())
-       {
-               SocketIOHookModule.erase(x);
-               return true;
-       }
-       return false;
-}
-
 void ServerConfig::Update005()
 {
        std::stringstream out(data005);
index c7188b55a1dad76572c8e6c4efb6cbc651d0e4f8..74f8c18617a464b667430ba3fa46513d12d283a8 100644 (file)
 #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;