summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cmd_quit.cpp4
-rw-r--r--src/command_parse.cpp5
-rw-r--r--src/commands.cpp6
-rw-r--r--src/helperfuncs.cpp1
-rw-r--r--src/inspircd.cpp24
-rw-r--r--src/modules.cpp5
-rw-r--r--src/userprocess.cpp48
-rw-r--r--src/users.cpp11
8 files changed, 35 insertions, 69 deletions
diff --git a/src/cmd_quit.cpp b/src/cmd_quit.cpp
index d8447c1de..b9fcc9db5 100644
--- a/src/cmd_quit.cpp
+++ b/src/cmd_quit.cpp
@@ -36,7 +36,6 @@
#include "commands/cmd_quit.h"
extern InspIRCd* ServerInstance;
-extern InspIRCd* ServerInstance;
extern int MODCOUNT;
extern ModuleList modules;
extern FactoryList factory;
@@ -44,7 +43,6 @@ extern time_t TIME;
extern user_hash clientlist;
extern chan_hash chanlist;
extern std::vector<userrec*> local_users;
-extern userrec* fd_ref_table[MAX_DESCRIPTORS];
void cmd_quit::Handle (const char** parameters, int pcnt, userrec *user)
{
@@ -112,6 +110,6 @@ void cmd_quit::Handle (const char** parameters, int pcnt, userrec *user)
purge_empty_chans(user);
}
if (user->fd > -1)
- fd_ref_table[user->fd] = NULL;
+ ServerInstance->fd_ref_table[user->fd] = NULL;
DELETE(user);
}
diff --git a/src/command_parse.cpp b/src/command_parse.cpp
index 25a3ca192..a0097b924 100644
--- a/src/command_parse.cpp
+++ b/src/command_parse.cpp
@@ -58,11 +58,6 @@ extern std::vector<userrec*> local_users;
extern int MODCOUNT;
extern time_t TIME;
-// This table references users by file descriptor.
-// its an array to make it VERY fast, as all lookups are referenced
-// by an integer, meaning there is no need for a scan/search operation.
-extern userrec* fd_ref_table[MAX_DESCRIPTORS];
-
extern Server* MyServer;
extern user_hash clientlist;
diff --git a/src/commands.cpp b/src/commands.cpp
index b8788864b..9a6be7206 100644
--- a/src/commands.cpp
+++ b/src/commands.cpp
@@ -69,12 +69,6 @@ extern chan_hash chanlist;
extern std::vector<userrec*> all_opers;
extern std::vector<userrec*> local_users;
-// This table references users by file descriptor.
-// its an array to make it VERY fast, as all lookups are referenced
-// by an integer, meaning there is no need for a scan/search operation.
-extern userrec* fd_ref_table[MAX_DESCRIPTORS];
-
-
void split_chlist(userrec* user, userrec* dest, const std::string &cl)
{
std::string line;
diff --git a/src/helperfuncs.cpp b/src/helperfuncs.cpp
index 5adc18650..be8c9ac67 100644
--- a/src/helperfuncs.cpp
+++ b/src/helperfuncs.cpp
@@ -49,7 +49,6 @@ extern ModuleList modules;
extern InspIRCd* ServerInstance;
extern time_t TIME;
extern char lowermap[255];
-extern userrec* fd_ref_table[MAX_DESCRIPTORS];
extern std::vector<userrec*> all_opers;
extern user_hash clientlist;
extern chan_hash chanlist;
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 242183303..e272d4c6e 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -82,10 +82,6 @@ socklen_t length;
time_t TIME = time(NULL), OLDTIME = time(NULL);
-// This table references users by file descriptor.
-// its an array to make it VERY fast, as all lookups are referenced
-// by an integer, meaning there is no need for a scan/search operation.
-userrec* fd_ref_table[MAX_DESCRIPTORS];
Server* MyServer = new Server;
user_hash clientlist;
chan_hash chanlist;
@@ -708,18 +704,6 @@ void InspIRCd::DoOneIteration(bool process_module_sockets)
expire_lines();
if (process_module_sockets)
{
- /* Fix by brain - the addition of DoOneIteration means that this
- * can end up getting called recursively in the following pattern:
- *
- * m_spanningtree DoPingChecks
- * (server pings out and is squit)
- * (squit causes call to DoOneIteration)
- * DoOneIteration enters here
- * calls DoBackground timer
- * enters m_spanningtree DoPingChecks... see step 1.
- *
- * This should do the job and fix the bug.
- */
FOREACH_MOD(I_OnBackgroundTimer,OnBackgroundTimer(TIME));
}
TickMissedTimers(TIME);
@@ -734,7 +718,7 @@ void InspIRCd::DoOneIteration(bool process_module_sockets)
if (iterations++ == 15)
{
iterations = 0;
- DoBackgroundUserStuff(TIME);
+ this->DoBackgroundUserStuff(TIME);
}
/* Once a second, do the background processing */
@@ -754,7 +738,7 @@ void InspIRCd::DoOneIteration(bool process_module_sockets)
* hit at all.
*/
if (process_module_sockets)
- DoSocketTimeouts(TIME,this);
+ this->DoSocketTimeouts(TIME);
TickTimers(TIME);
@@ -783,9 +767,9 @@ void InspIRCd::DoOneIteration(bool process_module_sockets)
case X_ESTAB_CLIENT:
log(DEBUG,"Type: X_ESTAB_CLIENT: fd=%d",activefds[activefd]);
- cu = fd_ref_table[activefds[activefd]];
+ cu = this->fd_ref_table[activefds[activefd]];
if (cu)
- ProcessUser(cu);
+ this->ProcessUser(cu);
break;
diff --git a/src/modules.cpp b/src/modules.cpp
index 4b2d12cab..4eed4d781 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -51,7 +51,6 @@ extern ModuleList modules;
extern FactoryList factory;
extern std::vector<userrec*> local_users;
extern time_t TIME;
-extern userrec* fd_ref_table[MAX_DESCRIPTORS];
extern user_hash clientlist;
extern chan_hash chanlist;
extern command_table cmdlist;
@@ -460,7 +459,7 @@ userrec* Server::FindNick(const std::string &nick)
userrec* Server::FindDescriptor(int socket)
{
- return (socket < 65536 ? fd_ref_table[socket] : NULL);
+ return (socket < 65536 ? ServerInstance->fd_ref_table[socket] : NULL);
}
chanrec* Server::FindChannel(const std::string &channel)
@@ -558,7 +557,7 @@ bool Server::PseudoToUser(userrec* alive, userrec* zombie, const std::string &me
log(DEBUG,"Delete local user");
}
// Fix by brain - cant write the user until their fd table entry is updated
- fd_ref_table[zombie->fd] = zombie;
+ ServerInstance->fd_ref_table[zombie->fd] = zombie;
zombie->Write(":%s!%s@%s NICK %s",oldnick.c_str(),oldident.c_str(),oldhost.c_str(),zombie->nick);
for (std::vector<ucrec*>::const_iterator i = zombie->chans.begin(); i != zombie->chans.end(); i++)
{
diff --git a/src/userprocess.cpp b/src/userprocess.cpp
index 7d4ce9442..b2c8034a3 100644
--- a/src/userprocess.cpp
+++ b/src/userprocess.cpp
@@ -59,14 +59,12 @@ extern std::vector<ircd_module*> factory;
extern time_t TIME;
extern time_t OLDTIME;
extern std::vector<userrec*> local_users;
-extern InspIRCd* ServerInstance;
-extern userrec* fd_ref_table[MAX_DESCRIPTORS];
char data[65536];
extern user_hash clientlist;
extern chan_hash chanlist;
-void ProcessUser(userrec* cu)
+void InspIRCd::ProcessUser(userrec* cu)
{
int result = EAGAIN;
@@ -75,14 +73,14 @@ void ProcessUser(userrec* cu)
log(DEBUG,"Processing user with fd %d",cu->fd);
- if (ServerInstance->Config->GetIOHook(cu->GetPort()))
+ if (this->Config->GetIOHook(cu->GetPort()))
{
int result2 = 0;
int MOD_RESULT = 0;
try
{
- MOD_RESULT = ServerInstance->Config->GetIOHook(cu->GetPort())->OnRawSocketRead(cu->fd,data,65535,result2);
+ MOD_RESULT = this->Config->GetIOHook(cu->GetPort())->OnRawSocketRead(cu->fd,data,65535,result2);
log(DEBUG,"Data result returned by module: %d",MOD_RESULT);
}
catch (ModuleException& modexcept)
@@ -112,7 +110,7 @@ void ProcessUser(userrec* cu)
int currfd;
int floodlines = 0;
- ServerInstance->stats->statsRecv += result;
+ this->stats->statsRecv += result;
/*
* perform a check on the raw buffer as an array (not a string!) to remove
* character 0 which is illegal in the RFC - replace them with spaces.
@@ -166,14 +164,14 @@ void ProcessUser(userrec* cu)
{
WriteOpers("*** Excess flood from %s",current->GetIPString());
log(DEFAULT,"Excess flood from: %s",current->GetIPString());
- add_zline(120,ServerInstance->Config->ServerName,"Flood from unregistered connection",current->GetIPString());
+ add_zline(120,this->Config->ServerName,"Flood from unregistered connection",current->GetIPString());
apply_lines(APPLY_ZLINES);
}
return;
}
- if (current->recvq.length() > (unsigned)ServerInstance->Config->NetBufferSize)
+ if (current->recvq.length() > (unsigned)this->Config->NetBufferSize)
{
if (current->registered == REG_ALL)
{
@@ -183,7 +181,7 @@ void ProcessUser(userrec* cu)
{
WriteOpers("*** Excess flood from %s",current->GetIPString());
log(DEFAULT,"Excess flood from: %s",current->GetIPString());
- add_zline(120,ServerInstance->Config->ServerName,"Flood from unregistered connection",current->GetIPString());
+ add_zline(120,this->Config->ServerName,"Flood from unregistered connection",current->GetIPString());
apply_lines(APPLY_ZLINES);
}
@@ -217,7 +215,7 @@ void ProcessUser(userrec* cu)
}
else
{
- add_zline(120,ServerInstance->Config->ServerName,"Flood from unregistered connection",current->GetIPString());
+ add_zline(120,this->Config->ServerName,"Flood from unregistered connection",current->GetIPString());
apply_lines(APPLY_ZLINES);
}
@@ -231,17 +229,17 @@ void ProcessUser(userrec* cu)
if (single_line.length() > 512)
single_line.resize(512);
- userrec* old_comp = fd_ref_table[currfd];
+ userrec* old_comp = this->fd_ref_table[currfd];
- ServerInstance->Parser->ProcessBuffer(single_line,current);
+ this->Parser->ProcessBuffer(single_line,current);
/*
* look for the user's record in case it's changed... if theyve quit,
* we cant do anything more with their buffer, so bail.
* there used to be an ugly, slow loop here. Now we have a reference
* table, life is much easier (and FASTER)
*/
- userrec* new_comp = fd_ref_table[currfd];
- if ((currfd < 0) || (!fd_ref_table[currfd]) || (old_comp != new_comp))
+ userrec* new_comp = this->fd_ref_table[currfd];
+ if ((currfd < 0) || (!this->fd_ref_table[currfd]) || (old_comp != new_comp))
{
return;
}
@@ -277,26 +275,26 @@ void ProcessUser(userrec* cu)
}
}
-void DoSocketTimeouts(time_t TIME, InspIRCd* SI)
+void InspIRCd::DoSocketTimeouts(time_t TIME)
{
- unsigned int numsockets = SI->module_sockets.size();
- SocketEngine* SE = SI->SE;
+ unsigned int numsockets = this->module_sockets.size();
+ SocketEngine* SE = this->SE;
- for (std::vector<InspSocket*>::iterator a = SI->module_sockets.begin(); a < SI->module_sockets.end(); a++)
+ for (std::vector<InspSocket*>::iterator a = this->module_sockets.begin(); a < this->module_sockets.end(); a++)
{
InspSocket* s = (InspSocket*)*a;
- if ((s) && (s->GetFd() >= 0) && (s->GetFd() < MAX_DESCRIPTORS) && (SI->socket_ref[s->GetFd()] != NULL) && (s->Timeout(TIME)))
+ if ((s) && (s->GetFd() >= 0) && (s->GetFd() < MAX_DESCRIPTORS) && (this->socket_ref[s->GetFd()] != NULL) && (s->Timeout(TIME)))
{
log(DEBUG,"userprocess.cpp: Socket poll returned false, close and bail");
- SI->socket_ref[s->GetFd()] = NULL;
+ this->socket_ref[s->GetFd()] = NULL;
SE->DelFd(s->GetFd());
- SI->module_sockets.erase(a);
+ this->module_sockets.erase(a);
s->Close();
DELETE(s);
break;
}
- if (SI->module_sockets.size() != numsockets)
+ if (this->module_sockets.size() != numsockets)
break;
}
}
@@ -307,7 +305,7 @@ void DoSocketTimeouts(time_t TIME, InspIRCd* SI)
* stuff like ping checks, registration timeouts, etc. This function is
* also responsible for checking if InspSocket derived classes are timed out.
*/
-void DoBackgroundUserStuff(time_t TIME)
+void InspIRCd::DoBackgroundUserStuff(time_t TIME)
{
CullList GlobalGoners;
@@ -340,7 +338,7 @@ void DoBackgroundUserStuff(time_t TIME)
{
curr->dns_done = true;
//ZapThisDns(curr->fd);
- ServerInstance->stats->statsDnsBad++;
+ this->stats->statsDnsBad++;
curr->FullConnect(&GlobalGoners);
continue;
}
@@ -362,7 +360,7 @@ void DoBackgroundUserStuff(time_t TIME)
curr->nping = TIME+curr->pingmax;
continue;
}
- curr->Write("PING :%s",ServerInstance->Config->ServerName);
+ curr->Write("PING :%s",this->Config->ServerName);
curr->lastping = 0;
curr->nping = TIME+curr->pingmax;
}
diff --git a/src/users.cpp b/src/users.cpp
index 53e4695f6..6faea40ce 100644
--- a/src/users.cpp
+++ b/src/users.cpp
@@ -38,7 +38,6 @@ extern std::vector<ircd_module*> factory;
extern std::vector<InspSocket*> module_sockets;
extern int MODCOUNT;
extern time_t TIME;
-extern userrec* fd_ref_table[MAX_DESCRIPTORS];
extern user_hash clientlist;
extern Server* MyServer;
extern std::vector<userrec*> local_users;
@@ -154,7 +153,7 @@ UserResolver::UserResolver(userrec* user, std::string to_resolve, bool forward)
void UserResolver::OnLookupComplete(const std::string &result)
{
- if ((!this->fwd) && (fd_ref_table[this->bound_fd] == this->bound_user))
+ if ((!this->fwd) && (ServerInstance->fd_ref_table[this->bound_fd] == this->bound_user))
{
log(DEBUG,"Commencing forward lookup");
this->bound_user->stored_host = result;
@@ -168,7 +167,7 @@ void UserResolver::OnLookupComplete(const std::string &result)
log(DEBUG,"Error in resolver: %s",e.GetReason());
}
}
- else if ((this->fwd) && (fd_ref_table[this->bound_fd] == this->bound_user))
+ else if ((this->fwd) && (ServerInstance->fd_ref_table[this->bound_fd] == this->bound_user))
{
/* Both lookups completed */
if (this->bound_user->GetIPString() == result)
@@ -199,7 +198,7 @@ void UserResolver::OnLookupComplete(const std::string &result)
void UserResolver::OnError(ResolverError e, const std::string &errormessage)
{
- if (fd_ref_table[this->bound_fd] == this->bound_user)
+ if (ServerInstance->fd_ref_table[this->bound_fd] == this->bound_user)
{
/* Error message here */
this->bound_user->WriteServ("NOTICE Auth :*** Could not resolve your hostname, using your IP address (%s) instead.", this->bound_user->GetIPString());
@@ -714,7 +713,7 @@ void userrec::QuitUser(userrec *user,const std::string &quitreason)
log(DEBUG,"deleting user hash value %lx",(unsigned long)user);
if (IS_LOCAL(user))
{
- fd_ref_table[user->fd] = NULL;
+ ServerInstance->fd_ref_table[user->fd] = NULL;
if (find(local_users.begin(),local_users.end(),user) != local_users.end())
local_users.erase(find(local_users.begin(),local_users.end(),user));
}
@@ -874,7 +873,7 @@ void userrec::AddClient(int socket, int port, bool iscached, insp_inaddr ip)
_new->sendqmax = class_sqmax;
_new->recvqmax = class_rqmax;
- fd_ref_table[socket] = _new;
+ ServerInstance->fd_ref_table[socket] = _new;
local_users.push_back(_new);
if (local_users.size() > ServerInstance->Config->SoftLimit)