]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/xline.cpp
Signed octets in dns forward lookup! GAH
[user/henk/code/inspircd.git] / src / xline.cpp
index 7e96d0940e58a9ce38a854b8945d05551dffef8c..7a6db9a61cd857194ea68d05d0725b49d9fcfb55 100644 (file)
  * ---------------------------------------------------
  */
 
+using namespace std;
+
+#include "inspircd_config.h"
 #include "inspircd.h"
 #include "inspircd_io.h"
 #include "inspircd_util.h"
-#include "inspircd_config.h"
 #include <unistd.h>
 #include <fcntl.h>
 #include <sys/errno.h>
@@ -32,9 +34,7 @@
 #include <sstream>
 #include <vector>
 #include <deque>
-#include "connection.h"
 #include "users.h"
-#include "servers.h"
 #include "ctables.h"
 #include "globals.h"
 #include "modules.h"
 #include "helperfuncs.h"
 #include "hashcomp.h"
 
-using namespace std;
-
 extern int MODCOUNT;
-extern std::vector<Module*, __single_client_alloc> modules;
-extern std::vector<ircd_module*, __single_client_alloc> factory;
+extern std::vector<Module*> modules;
+extern std::vector<ircd_module*> factory;
 
 extern int LogLevel;
 extern char ServerName[MAXBUF];
@@ -76,26 +74,22 @@ extern time_t startup_time;
 extern int NetBufferSize;
 extern time_t nb_start;
 
-extern std::vector<std::string, __single_client_alloc> module_names;
+extern std::vector<std::string> module_names;
 
 extern int boundPortCount;
 extern int portCount;
-extern int SERVERportCount;
+
 extern int ports[MAXSOCKS];
-extern int defaultRoute;
 
-extern std::vector<long> auth_cookies;
 extern std::stringstream config_f;
 
-extern serverrec* me[32];
-
 extern FILE *log_file;
 
-typedef nspace::hash_map<std::string, userrec*, nspace::hash<string>, irc::StrHashComp, __single_client_alloc> user_hash;
-typedef nspace::hash_map<std::string, chanrec*, nspace::hash<string>, irc::StrHashComp, __single_client_alloc> chan_hash;
-typedef nspace::hash_map<in_addr,string*, nspace::hash<in_addr>, irc::InAddr_HashComp, __single_client_alloc> address_cache;
-typedef nspace::hash_map<std::string, WhoWasUser*, nspace::hash<string>, irc::StrHashComp, __single_client_alloc> whowas_hash;
-typedef std::deque<command_t, __single_client_alloc> command_table;
+typedef nspace::hash_map<std::string, userrec*, nspace::hash<string>, irc::StrHashComp> user_hash;
+typedef nspace::hash_map<std::string, chanrec*, nspace::hash<string>, irc::StrHashComp> chan_hash;
+typedef nspace::hash_map<in_addr,string*, nspace::hash<in_addr>, irc::InAddr_HashComp> address_cache;
+typedef nspace::hash_map<std::string, WhoWasUser*, nspace::hash<string>, irc::StrHashComp> whowas_hash;
+typedef std::deque<command_t> command_table;
 
 
 extern user_hash clientlist;
@@ -312,36 +306,6 @@ bool zline_make_global(const char* ipaddr)
        return false;
 }
 
-void sync_xlines(serverrec* serv, char* tcp_host)
-{
-       char data[MAXBUF];
-       
-       // for zlines and qlines, we should first check if theyre global...
-       for (std::vector<ZLine>::iterator i = zlines.begin(); i != zlines.end(); i++)
-       {
-               if (i->is_global)
-               {
-                       snprintf(data,MAXBUF,"%s } %s %s %lu %lu :%s",CreateSum().c_str(),i->ipaddr,i->source,(unsigned long)i->set_time,(unsigned long)i->duration,i->reason);
-                       serv->SendPacket(data,tcp_host);
-               }
-       }
-       for (std::vector<QLine>::iterator i = qlines.begin(); i != qlines.end(); i++)
-       {
-               if (i->is_global)
-               {
-                       snprintf(data,MAXBUF,"%s { %s %s %lu %lu :%s",CreateSum().c_str(),i->nick,i->source,(unsigned long)i->set_time,(unsigned long)i->duration,i->reason);
-                       serv->SendPacket(data,tcp_host);
-               }
-       }
-       // glines are always global, so no need to check
-       for (std::vector<GLine>::iterator i = glines.begin(); i != glines.end(); i++)
-       {
-               snprintf(data,MAXBUF,"%s # %s %s %lu %lu :%s",CreateSum().c_str(),i->hostmask,i->source,(unsigned long)i->set_time,(unsigned long)i->duration,i->reason);
-               serv->SendPacket(data,tcp_host);
-       }
-}
-
-
 // deletes a z:line, returns true if the line existed and was removed
 
 bool del_zline(const char* ipaddr)
@@ -501,6 +465,12 @@ void expire_lines()
        
        // because we mess up an iterator when we remove from the vector, we must bail from
        // the loop early if we delete an item, therefore this outer while loop is required.
+       //
+       // 30/11/2005-- I can imagine that if we get a large number of *lines, this would perform dog slow.
+       // While we try and think of a better solution, for now I've simply split the loops up, instead of
+       // one huge while () -- this means if we remove a g-line, we only need to re-check glines, not z/g/.
+       // lines too, hopefully a little faster, even if it looks a little messier ;) --w00t
+
        while (go_again)
        {
                go_again = false;
@@ -515,6 +485,13 @@ void expire_lines()
                                break;
                        }
                }
+       }
+
+       go_again = true;
+
+       while (go_again)
+       {
+               go_again = false;
 
                 for (std::vector<ELine>::iterator i = elines.begin(); i != elines.end(); i++)
                 {
@@ -526,6 +503,13 @@ void expire_lines()
                                 break;
                         }
                 }
+       }
+
+       go_again = true;
+
+       while (go_again)
+       {
+               go_again = false;
 
                for (std::vector<GLine>::iterator i = glines.begin(); i != glines.end(); i++)
                {
@@ -537,6 +521,13 @@ void expire_lines()
                                break;
                        }
                }
+       }
+
+       go_again = true;
+
+       while (go_again)
+       {
+               go_again = false;
 
                for (std::vector<ZLine>::iterator i = zlines.begin(); i != zlines.end(); i++)
                {
@@ -548,6 +539,14 @@ void expire_lines()
                                break;
                        }
                }
+       }
+
+       go_again = true;
+
+
+       while (go_again)
+       {
+               go_again = false;
 
                for (std::vector<QLine>::iterator i = qlines.begin(); i != qlines.end(); i++)
                {