From 0b675b72d5ca8a963734ca838e8ae81230046a66 Mon Sep 17 00:00:00 2001 From: brain Date: Fri, 16 Dec 2005 01:05:11 +0000 Subject: Moving to faster way of hooking i/o git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@2499 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/helperfuncs.cpp | 45 ++++++++++++++++++++++++++++++++++----------- src/modules.cpp | 3 +++ 2 files changed, 37 insertions(+), 11 deletions(-) diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp index c886acf3c..3f7e89d57 100644 --- a/src/helperfuncs.cpp +++ b/src/helperfuncs.cpp @@ -62,6 +62,7 @@ extern std::vector 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(); } diff --git a/src/modules.cpp b/src/modules.cpp index b58964b57..c2fa1a036 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -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) { -- cgit v1.2.3