]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
Moving to faster way of hooking i/o
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Fri, 16 Dec 2005 01:05:11 +0000 (01:05 +0000)
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>
Fri, 16 Dec 2005 01:05:11 +0000 (01:05 +0000)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2499 e03df62e-2008-0410-955e-edbf42e46eb7

src/helperfuncs.cpp
src/modules.cpp

index c886acf3c081d83fd022a62a22d88ec8e56bbbb1..3f7e89d576d8577deabeebe9a84b39cfd1a33fa6 100644 (file)
@@ -62,6 +62,7 @@ extern std::vector<userrec*> all_opers;
 extern user_hash clientlist;
 extern chan_hash chanlist;
 extern command_table cmdlist;
+extern Module* IOHookModule;
 
 static char textbuffer[MAXBUF];
 static char tb[MAXBUF];
@@ -143,10 +144,15 @@ void Write(int sock,char *text, ...)
         chop(tb);
         if (fd_ref_table[sock])
         {
-                int MOD_RESULT = 0;
-                FOREACH_RESULT(OnRawSocketWrite(sock,tb,bytes));
-                fd_ref_table[sock]->AddWriteBuf(tb);
-                stats->statsSent += bytes;
+               if (IOHookModule)
+               {
+                       IOHookModule->OnRawSocketWrite(sock,tb,bytes);
+               }
+               else
+               {
+                       fd_ref_table[sock]->AddWriteBuf(tb);
+               }
+               stats->statsSent += bytes;
         }
         else log(DEFAULT,"ERROR! attempted write to a user with no fd_ref_table entry!!!");
 }
@@ -171,9 +177,14 @@ void WriteServ(int sock, char* text, ...)
         chop(tb);
         if (fd_ref_table[sock])
         {
-                int MOD_RESULT = 0;
-                FOREACH_RESULT(OnRawSocketWrite(sock,tb,bytes));
-                fd_ref_table[sock]->AddWriteBuf(tb);
+               if (IOHookModule)
+               {
+                       IOHookModule->OnRawSocketWrite(sock,tb,bytes);
+               }
+               else
+               {
+                       fd_ref_table[sock]->AddWriteBuf(tb);
+               }
                 stats->statsSent += bytes;
         }
         else log(DEFAULT,"ERROR! attempted write to a user with no fd_ref_table entry!!!");
@@ -199,9 +210,14 @@ void WriteFrom(int sock, userrec *user,char* text, ...)
         chop(tb);
         if (fd_ref_table[sock])
         {
-                int MOD_RESULT = 0;
-                FOREACH_RESULT(OnRawSocketWrite(sock,tb,bytes));
-                fd_ref_table[sock]->AddWriteBuf(tb);
+               if (IOHookModule)
+               {
+                       IOHookModule->OnRawSocketWrite(sock,tb,bytes);
+               }
+               else
+               {
+                       fd_ref_table[sock]->AddWriteBuf(tb);
+               }
                 stats->statsSent += bytes;
         }
         else log(DEFAULT,"ERROR! attempted write to a user with no fd_ref_table entry!!!");
@@ -1052,7 +1068,14 @@ void ShowMOTD(userrec *user)
         snprintf(mbuf,MAXBUF,":%s 376 %s :End of message of the day.\r\n", Config->ServerName, user->nick);
         WholeMOTD = WholeMOTD + mbuf;
         // only one write operation
-        user->AddWriteBuf(WholeMOTD);
+       if (IOHookModule)
+       {
+               IOHookModule->OnRawSocketWrite(user->fd,(char*)WholeMOTD.c_str(),WholeMOTD.length());
+       }
+       else
+       {
+               user->AddWriteBuf(WholeMOTD);
+       }
         stats->statsSent += WholeMOTD.length();
 }
 
index b58964b5711192d65fc9c0a6079900c123ac48fd..c2fa1a03623c4cbe238330419f89c82ed085818d 100644 (file)
@@ -48,6 +48,7 @@ using namespace std;
 #include "socket.h"
 #include "socketengine.h"
 #include "typedefs.h"
+#include "modules.h"
 
 extern SocketEngine* SE;
 extern ServerConfig *Config;
@@ -66,6 +67,8 @@ extern chan_hash chanlist;
 extern command_table cmdlist;
 ExtModeList EMode;
 
+Module* IOHookModule;
+
 // returns true if an extended mode character is in use
 bool ModeDefined(char modechar, int type)
 {