From 2db77cda56947d4ee0f913c8082f6607855ca713 Mon Sep 17 00:00:00 2001 From: brain Date: Wed, 2 Apr 2008 17:08:09 +0000 Subject: Automatic detection and allocation of max fds. No longer needs recompile to change, just adjust it in your kernel or whatever and restart insp. Please note that select and iocp socket engines do not support detection and are always set to FD_SETSIZE and 10240 descriptors respectively. git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@9263 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/users.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'src/users.cpp') diff --git a/src/users.cpp b/src/users.cpp index df7a36683..361b7ba21 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -21,7 +21,13 @@ #include "bancache.h" #include "commands/cmd_whowas.h" -static unsigned long already_sent[MAX_DESCRIPTORS] = {0}; +static unsigned long* already_sent = NULL; + + +void InitializeAlreadySent(SocketEngine* SE) +{ + already_sent = new unsigned long[SE->GetMaxFds()]; +} /* XXX: Used for speeding up WriteCommon operations */ unsigned long uniq_id = 0; @@ -1322,6 +1328,9 @@ void User::WriteCommon(const std::string &text) uniq_id++; + if (!already_sent) + InitializeAlreadySent(ServerInstance->SE); + /* We dont want to be doing this n times, just once */ snprintf(tb,MAXBUF,":%s %s",this->GetFullHost(),text.c_str()); std::string out = tb; @@ -1376,6 +1385,10 @@ void User::WriteCommonQuit(const std::string &normal_text, const std::string &op return; uniq_id++; + + if (!already_sent) + InitializeAlreadySent(ServerInstance->SE); + snprintf(tb1,MAXBUF,":%s QUIT :%s",this->GetFullHost(),normal_text.c_str()); snprintf(tb2,MAXBUF,":%s QUIT :%s",this->GetFullHost(),oper_text.c_str()); std::string out1 = tb1; @@ -1407,6 +1420,10 @@ void User::WriteCommonExcept(const std::string &text) return; uniq_id++; + + if (!already_sent) + InitializeAlreadySent(ServerInstance->SE); + snprintf(tb1,MAXBUF,":%s %s",this->GetFullHost(),text.c_str()); out1 = tb1; -- cgit v1.2.3