diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-08-09 14:53:19 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-08-09 14:53:19 +0000 |
commit | ab46b96db4d457e6a4f2e978c38b79762cdeb9d5 (patch) | |
tree | 01b9489ae9804ee45b765ad7045efee54b34347b | |
parent | f0680338833dd76966ba1769980abb9eafb50467 (diff) |
Move socket_ref and module_sockets vectors/arrays into InspIRCd*. These are public members, which InspSocket can modify.
(eventually, this will be marshalled safely through some accessors). When constructing an InspSocket you must now provide
an InspIRCd* instance to 'attach' the socket to.
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@4812 e03df62e-2008-0410-955e-edbf42e46eb7
-rw-r--r-- | include/inspircd.h | 2 | ||||
-rw-r--r-- | include/inspsocket.h | 8 | ||||
-rw-r--r-- | include/userprocess.h | 2 | ||||
-rw-r--r-- | src/inspircd.cpp | 10 | ||||
-rw-r--r-- | src/inspsocket.cpp | 45 | ||||
-rw-r--r-- | src/modules.cpp | 9 | ||||
-rw-r--r-- | src/modules/extra/m_mysql.cpp | 10 | ||||
-rw-r--r-- | src/modules/extra/m_pgsql.cpp | 11 | ||||
-rw-r--r-- | src/modules/m_httpd.cpp | 10 | ||||
-rw-r--r-- | src/modules/m_ident.cpp | 6 | ||||
-rw-r--r-- | src/modules/m_spanningtree.cpp | 22 | ||||
-rw-r--r-- | src/userprocess.cpp | 19 |
12 files changed, 77 insertions, 77 deletions
diff --git a/include/inspircd.h b/include/inspircd.h index 91d57f75d..54500cd4d 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -104,6 +104,8 @@ class InspIRCd : public classbase SocketEngine* SE; serverstats* stats; ServerConfig* Config; + std::vector<InspSocket*> module_sockets; + InspSocket* socket_ref[MAX_DESCRIPTORS]; DNS* Res; std::string GetRevision(); diff --git a/include/inspsocket.h b/include/inspsocket.h index d2a8ed522..42ce01a27 100644 --- a/include/inspsocket.h +++ b/include/inspsocket.h @@ -35,6 +35,7 @@ enum InspSocketState { I_DISCONNECTED, I_CONNECTING, I_CONNECTED, I_LISTENING, I enum InspSocketError { I_ERR_TIMEOUT, I_ERR_SOCKET, I_ERR_CONNECT, I_ERR_BIND, I_ERR_RESOLVE, I_ERR_WRITE, I_ERR_NOMOREFDS }; class InspSocket; +class InspIRCd; /** * InspSocket is an extendable socket class which modules @@ -50,6 +51,7 @@ class InspSocket; class InspSocket : public Extensible { public: + InspIRCd* Instance; std::deque<std::string> outbuffer; @@ -165,7 +167,7 @@ class InspSocket : public Extensible * The default constructor does nothing * and should not be used. */ - InspSocket(); + InspSocket(InspIRCd* SI); /** * This constructor is used to associate @@ -175,7 +177,7 @@ class InspSocket : public Extensible * will be set with the given IP address * and placed in CONNECTED state. */ - InspSocket(int newfd, const char* ip); + InspSocket(InspIRCd* SI, int newfd, const char* ip); /** * This constructor is used to create a new @@ -188,7 +190,7 @@ class InspSocket : public Extensible * @param listening true to listen on the given host:port pair, or false to connect to them * @param maxtime Number of seconds to wait, if connecting, before the connection times out and an OnTimeout() event is generated */ - InspSocket(const std::string &ipaddr, int port, bool listening, unsigned long maxtime); + InspSocket(InspIRCd* SI, const std::string &ipaddr, int port, bool listening, unsigned long maxtime); /** * This method is called when an outbound diff --git a/include/userprocess.h b/include/userprocess.h index cc3d713a0..1a93e68cd 100644 --- a/include/userprocess.h +++ b/include/userprocess.h @@ -10,6 +10,6 @@ void CheckRoot(); void OpenLog(char** argv, int argc); void DoBackgroundUserStuff(time_t TIME); void ProcessUser(userrec* cu); -void DoSocketTimeouts(time_t TIME); +void DoSocketTimeouts(time_t TIME, InspIRCd* SI); #endif diff --git a/src/inspircd.cpp b/src/inspircd.cpp index c92e862b0..242183303 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -70,7 +70,6 @@ InspIRCd* ServerInstance; extern ModuleList modules; extern FactoryList factory; -std::vector<InspSocket*> module_sockets; std::vector<userrec*> local_users; extern int MODCOUNT; @@ -81,7 +80,6 @@ int iterations = 0; insp_sockaddr client, server; socklen_t length; -extern InspSocket* socket_ref[MAX_DESCRIPTORS]; time_t TIME = time(NULL), OLDTIME = time(NULL); // This table references users by file descriptor. @@ -236,7 +234,7 @@ InspIRCd::InspIRCd(int argc, char** argv) this->Config = new ServerConfig; ServerInstance = this; this->Start(); - module_sockets.clear(); + this->module_sockets.clear(); this->startup_time = time(NULL); srand(time(NULL)); log(DEBUG,"*** InspIRCd starting up!"); @@ -756,7 +754,7 @@ void InspIRCd::DoOneIteration(bool process_module_sockets) * hit at all. */ if (process_module_sockets) - DoSocketTimeouts(TIME); + DoSocketTimeouts(TIME,this); TickTimers(TIME); @@ -802,13 +800,13 @@ void InspIRCd::DoOneIteration(bool process_module_sockets) * Modules are encouraged to inherit their sockets from * InspSocket so we can process them neatly like this. */ - s = socket_ref[activefds[activefd]]; + s = this->socket_ref[activefds[activefd]]; if ((s) && (!s->Poll())) { log(DEBUG,"Socket poll returned false, close and bail"); SE->DelFd(s->GetFd()); - socket_ref[activefds[activefd]] = NULL; + this->socket_ref[activefds[activefd]] = NULL; for (std::vector<InspSocket*>::iterator a = module_sockets.begin(); a < module_sockets.end(); a++) { s_del = *a; diff --git a/src/inspsocket.cpp b/src/inspsocket.cpp index 5c8607f7d..6a0fbc556 100644 --- a/src/inspsocket.cpp +++ b/src/inspsocket.cpp @@ -21,43 +21,42 @@ #include <stdexcept> #include "inspircd_config.h" #include "socket.h" -#include "inspircd.h" #include "configreader.h" #include "inspstring.h" #include "helperfuncs.h" #include "socketengine.h" #include "message.h" +#include "inspircd.h" -extern InspIRCd* ServerInstance; extern time_t TIME; extern Server* MyServer; -InspSocket* socket_ref[MAX_DESCRIPTORS]; - - -InspSocket::InspSocket() +InspSocket::InspSocket(InspIRCd* SI) { this->state = I_DISCONNECTED; this->fd = -1; this->ClosePending = false; + this->Instance = SI; } -InspSocket::InspSocket(int newfd, const char* ip) +InspSocket::InspSocket(InspIRCd* SI, int newfd, const char* ip) { this->fd = newfd; this->state = I_CONNECTED; strlcpy(this->IP,ip,MAXBUF); this->ClosePending = false; + this->Instance = SI; if (this->fd > -1) { - this->ClosePending = (!ServerInstance->SE->AddFd(this->fd,true,X_ESTAB_MODULE)); - socket_ref[this->fd] = this; + this->ClosePending = (!this->Instance->SE->AddFd(this->fd,true,X_ESTAB_MODULE)); + this->Instance->socket_ref[this->fd] = this; } } -InspSocket::InspSocket(const std::string &ipaddr, int aport, bool listening, unsigned long maxtime) : fd(-1) +InspSocket::InspSocket(InspIRCd* SI, const std::string &ipaddr, int aport, bool listening, unsigned long maxtime) : fd(-1) { + this->Instance = SI; strlcpy(host,ipaddr.c_str(),MAXBUF); this->ClosePending = false; if (listening) { @@ -87,14 +86,14 @@ InspSocket::InspSocket(const std::string &ipaddr, int aport, bool listening, uns this->state = I_LISTENING; if (this->fd > -1) { - if (!ServerInstance->SE->AddFd(this->fd,true,X_ESTAB_MODULE)) + if (!this->Instance->SE->AddFd(this->fd,true,X_ESTAB_MODULE)) { this->Close(); this->state = I_ERROR; this->OnError(I_ERR_NOMOREFDS); this->ClosePending = true; } - socket_ref[this->fd] = this; + this->Instance->socket_ref[this->fd] = this; } log(DEBUG,"New socket now in I_LISTENING state"); return; @@ -139,8 +138,8 @@ void InspSocket::WantWrite() * This behaviour may be fixed in a later version. */ this->WaitingForWriteEvent = true; - ServerInstance->SE->DelFd(this->fd); - if (!ServerInstance->SE->AddFd(this->fd,false,X_ESTAB_MODULE)) + this->Instance->SE->DelFd(this->fd); + if (!this->Instance->SE->AddFd(this->fd,false,X_ESTAB_MODULE)) { this->Close(); this->fd = -1; @@ -265,7 +264,7 @@ bool InspSocket::DoConnect() this->state = I_CONNECTING; if (this->fd > -1) { - if (!ServerInstance->SE->AddFd(this->fd,false,X_ESTAB_MODULE)) + if (!this->Instance->SE->AddFd(this->fd,false,X_ESTAB_MODULE)) { this->OnError(I_ERR_NOMOREFDS); this->Close(); @@ -274,7 +273,7 @@ bool InspSocket::DoConnect() this->ClosePending = true; return false; } - socket_ref[this->fd] = this; + this->Instance->socket_ref[this->fd] = this; this->SetQueues(this->fd); } log(DEBUG,"Returning true from InspSocket::DoConnect"); @@ -289,7 +288,7 @@ void InspSocket::Close() this->OnClose(); shutdown(this->fd,2); close(this->fd); - socket_ref[this->fd] = NULL; + this->Instance->socket_ref[this->fd] = NULL; this->ClosePending = true; this->fd = -1; } @@ -390,7 +389,7 @@ bool InspSocket::FlushWriteBuffer() bool InspSocket::Timeout(time_t current) { - if (!socket_ref[this->fd] || !ServerInstance->SE->HasFd(this->fd)) + if (!this->Instance->socket_ref[this->fd] || !this->Instance->SE->HasFd(this->fd)) { log(DEBUG,"No FD or socket ref"); return false; @@ -421,7 +420,7 @@ bool InspSocket::Timeout(time_t current) bool InspSocket::Poll() { - if (!socket_ref[this->fd] || !ServerInstance->SE->HasFd(this->fd)) + if (!this->Instance->socket_ref[this->fd] || !this->Instance->SE->HasFd(this->fd)) return false; int incoming = -1; @@ -440,8 +439,8 @@ bool InspSocket::Poll() */ if (this->fd > -1) { - ServerInstance->SE->DelFd(this->fd); - if (!ServerInstance->SE->AddFd(this->fd,true,X_ESTAB_MODULE)) + this->Instance->SE->DelFd(this->fd); + if (!this->Instance->SE->AddFd(this->fd,true,X_ESTAB_MODULE)) return false; } return this->OnConnected(); @@ -462,8 +461,8 @@ bool InspSocket::Poll() if (this->WaitingForWriteEvent) { /* Switch back to read events */ - ServerInstance->SE->DelFd(this->fd); - if (!ServerInstance->SE->AddFd(this->fd,true,X_ESTAB_MODULE)) + this->Instance->SE->DelFd(this->fd); + if (!this->Instance->SE->AddFd(this->fd,true,X_ESTAB_MODULE)) return false; /* Trigger the write event */ diff --git a/src/modules.cpp b/src/modules.cpp index e49975500..4b2d12cab 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -49,7 +49,6 @@ extern InspIRCd* ServerInstance; extern int MODCOUNT; extern ModuleList modules; extern FactoryList factory; -extern std::vector<InspSocket*> module_sockets; extern std::vector<userrec*> local_users; extern time_t TIME; extern userrec* fd_ref_table[MAX_DESCRIPTORS]; @@ -247,12 +246,12 @@ Server::~Server() void Server::AddSocket(InspSocket* sock) { - module_sockets.push_back(sock); + ServerInstance->module_sockets.push_back(sock); } void Server::RemoveSocket(InspSocket* sock) { - for (std::vector<InspSocket*>::iterator a = module_sockets.begin(); a < module_sockets.end(); a++) + for (std::vector<InspSocket*>::iterator a = ServerInstance->module_sockets.begin(); a < ServerInstance->module_sockets.end(); a++) { InspSocket* s = (InspSocket*)*a; if (s == sock) @@ -346,11 +345,11 @@ std::string Server::GetVersion() void Server::DelSocket(InspSocket* sock) { - for (std::vector<InspSocket*>::iterator a = module_sockets.begin(); a < module_sockets.end(); a++) + for (std::vector<InspSocket*>::iterator a = ServerInstance->module_sockets.begin(); a < ServerInstance->module_sockets.end(); a++) { if (*a == sock) { - module_sockets.erase(a); + ServerInstance->module_sockets.erase(a); return; } } diff --git a/src/modules/extra/m_mysql.cpp b/src/modules/extra/m_mysql.cpp index 79baf170c..eeb803d5a 100644 --- a/src/modules/extra/m_mysql.cpp +++ b/src/modules/extra/m_mysql.cpp @@ -669,9 +669,9 @@ class Notifier : public InspSocket /* Create a socket on a random port. Let the tcp stack allocate us an available port */ #ifdef IPV6 - Notifier(Server* S) : InspSocket("::1", 0, true, 3000), Srv(S) + Notifier(InspIRCd* SI, Server* S) : InspSocket(SI, "::1", 0, true, 3000), Srv(S) #else - Notifier(Server* S) : InspSocket("127.0.0.1", 0, true, 3000), Srv(S) + Notifier(InspIRCd* SI, Server* S) : InspSocket(SI, "127.0.0.1", 0, true, 3000), Srv(S) #endif { uslen = sizeof(sock_us); @@ -681,7 +681,7 @@ class Notifier : public InspSocket } } - Notifier(int newfd, char* ip, Server* S) : InspSocket(newfd, ip), Srv(S) + Notifier(InspIRCd* SI, int newfd, char* ip, Server* S) : InspSocket(SI, newfd, ip), Srv(S) { log(DEBUG,"Constructor of new socket"); } @@ -699,7 +699,7 @@ class Notifier : public InspSocket virtual int OnIncomingConnection(int newsock, char* ip) { log(DEBUG,"Inbound connection on fd %d!",newsock); - Notifier* n = new Notifier(newsock, ip, Srv); + Notifier* n = new Notifier(this->Instance, newsock, ip, Srv); Srv->AddSocket(n); return true; } @@ -797,7 +797,7 @@ class ModuleSQL : public Module currid = 0; SQLModule = this; - MessagePipe = new Notifier(Srv); + MessagePipe = new Notifier(ServerInstance, Srv); Srv->AddSocket(MessagePipe); log(DEBUG,"Bound notifier to 127.0.0.1:%d",MessagePipe->GetPort()); diff --git a/src/modules/extra/m_pgsql.cpp b/src/modules/extra/m_pgsql.cpp index 5d07c23b5..b9eb309db 100644 --- a/src/modules/extra/m_pgsql.cpp +++ b/src/modules/extra/m_pgsql.cpp @@ -44,7 +44,6 @@ * I can access the socket engine :\ */ extern InspIRCd* ServerInstance; -extern InspSocket* socket_ref[MAX_DESCRIPTORS]; extern time_t TIME; /* Forward declare, so we can have the typedef neatly at the top */ @@ -474,7 +473,7 @@ public: /* This class should only ever be created inside this module, using this constructor, so we don't have to worry about the default ones */ - SQLConn(ModulePgSQL* self, Server* srv, const SQLhost& hostinfo); + SQLConn(InspIRCd* SI, ModulePgSQL* self, Server* srv, const SQLhost& hostinfo); ~SQLConn(); @@ -663,8 +662,8 @@ public: } }; -SQLConn::SQLConn(ModulePgSQL* self, Server* srv, const SQLhost& hi) -: InspSocket::InspSocket(), us(self), Srv(srv), dbhost(hi.host), dbport(hi.port), dbname(hi.name), dbuser(hi.user), dbpass(hi.pass), ssl(hi.ssl), sql(NULL), status(CWRITE), qinprog(false) +SQLConn::SQLConn(InspIRCd* SI, ModulePgSQL* self, Server* srv, const SQLhost& hi) +: InspSocket::InspSocket(SI), us(self), Srv(srv), dbhost(hi.host), dbport(hi.port), dbname(hi.name), dbuser(hi.user), dbpass(hi.pass), ssl(hi.ssl), sql(NULL), status(CWRITE), qinprog(false) { log(DEBUG, "Creating new PgSQL connection to database %s on %s:%u (%s/%s)", dbname.c_str(), dbhost.c_str(), dbport, dbuser.c_str(), dbpass.c_str()); @@ -741,7 +740,7 @@ bool SQLConn::DoConnect() Close(); return false; } - socket_ref[this->fd] = this; + Instance->socket_ref[this->fd] = this; /* Socket all hooked into the engine, now to tell PgSQL to start connecting */ @@ -753,7 +752,7 @@ void SQLConn::Close() log(DEBUG,"SQLConn::Close"); if(this->fd > 01) - socket_ref[this->fd] = NULL; + Instance->socket_ref[this->fd] = NULL; this->fd = -1; this->state = I_ERROR; this->OnError(I_ERR_SOCKET); diff --git a/src/modules/m_httpd.cpp b/src/modules/m_httpd.cpp index 0591ded9a..fb9ea954c 100644 --- a/src/modules/m_httpd.cpp +++ b/src/modules/m_httpd.cpp @@ -29,6 +29,8 @@ using namespace std; class ModuleHttp; +extern InspIRCd* ServerInstance; + static Server *Srv; static ModuleHttp* HttpModule; extern time_t TIME; @@ -49,13 +51,13 @@ class HttpSocket : public InspSocket public: - HttpSocket(std::string host, int port, bool listening, unsigned long maxtime, FileReader* index_page) : InspSocket(host, port, listening, maxtime), index(index_page) + HttpSocket(InspIRCd* SI, std::string host, int port, bool listening, unsigned long maxtime, FileReader* index_page) : InspSocket(SI, host, port, listening, maxtime), index(index_page) { log(DEBUG,"HttpSocket constructor"); InternalState = HTTP_LISTEN; } - HttpSocket(int newfd, char* ip, FileReader* ind) : InspSocket(newfd, ip), index(ind) + HttpSocket(InspIRCd* SI, int newfd, char* ip, FileReader* ind) : InspSocket(SI, newfd, ip), index(ind) { InternalState = HTTP_SERVE_WAIT_REQUEST; } @@ -64,7 +66,7 @@ class HttpSocket : public InspSocket { if (InternalState == HTTP_LISTEN) { - HttpSocket* s = new HttpSocket(newsock, ip, index); + HttpSocket* s = new HttpSocket(this->Instance, newsock, ip, index); Srv->AddSocket(s); } return true; @@ -276,7 +278,7 @@ class ModuleHttp : public Module void CreateListener() { - http = new HttpSocket(this->bindip, this->port, true, 0, &index); + http = new HttpSocket(ServerInstance, this->bindip, this->port, true, 0, &index); if ((http) && (http->GetState() == I_LISTENING)) { Srv->AddSocket(http); diff --git a/src/modules/m_ident.cpp b/src/modules/m_ident.cpp index 4de84ea06..d40bf045b 100644 --- a/src/modules/m_ident.cpp +++ b/src/modules/m_ident.cpp @@ -23,6 +23,8 @@ using namespace std; #include "modules.h" #include "inspircd.h" +extern InspIRCd* ServerInstance; + extern userrec* fd_ref_table[MAX_DESCRIPTORS]; /* $ModDesc: Provides support for RFC 1413 ident lookups */ @@ -43,7 +45,7 @@ class RFC1413 : public InspSocket userrec* u; // user record that the lookup is associated with int ufd; - RFC1413(userrec* user, int maxtime, Server* S) : InspSocket(user->GetIPString(), 113, false, maxtime), Srv(S), u(user), ufd(user->fd) + RFC1413(InspIRCd* SI, userrec* user, int maxtime, Server* S) : InspSocket(SI, user->GetIPString(), 113, false, maxtime), Srv(S), u(user), ufd(user->fd) { Srv->Log(DEBUG,"Ident: associated."); } @@ -209,7 +211,7 @@ class ModuleIdent : public Module * Server::AddSocket() call. */ user->WriteServ("NOTICE "+std::string(user->nick)+" :*** Looking up your ident..."); - RFC1413* ident = new RFC1413(user, IdentTimeout, Srv); + RFC1413* ident = new RFC1413(ServerInstance, user, IdentTimeout, Srv); if (ident->GetState() != I_ERROR) { user->Extend("ident_data", (char*)ident); diff --git a/src/modules/m_spanningtree.cpp b/src/modules/m_spanningtree.cpp index 7d011970e..448e3470b 100644 --- a/src/modules/m_spanningtree.cpp +++ b/src/modules/m_spanningtree.cpp @@ -663,8 +663,8 @@ class TreeSocket : public InspSocket * most of the action, and append a few of our own values * to it. */ - TreeSocket(std::string host, int port, bool listening, unsigned long maxtime) - : InspSocket(host, port, listening, maxtime) + TreeSocket(InspIRCd* SI, std::string host, int port, bool listening, unsigned long maxtime) + : InspSocket(SI, host, port, listening, maxtime) { myhost = host; this->LinkState = LISTENER; @@ -672,8 +672,8 @@ class TreeSocket : public InspSocket this->ctx_out = NULL; } - TreeSocket(std::string host, int port, bool listening, unsigned long maxtime, std::string ServerName) - : InspSocket(host, port, listening, maxtime) + TreeSocket(InspIRCd* SI, std::string host, int port, bool listening, unsigned long maxtime, std::string ServerName) + : InspSocket(SI, host, port, listening, maxtime) { myhost = ServerName; this->LinkState = CONNECTING; @@ -685,8 +685,8 @@ class TreeSocket : public InspSocket * we must associate it with a socket without creating a new * connection. This constructor is used for this purpose. */ - TreeSocket(int newfd, char* ip) - : InspSocket(newfd, ip) + TreeSocket(InspIRCd* SI, int newfd, char* ip) + : InspSocket(SI, newfd, ip) { this->LinkState = WAIT_AUTH_1; this->ctx_in = NULL; @@ -3069,7 +3069,7 @@ class TreeSocket : public InspSocket return false; } } - TreeSocket* s = new TreeSocket(newsock, ip); + TreeSocket* s = new TreeSocket(this->Instance, newsock, ip); Srv->AddSocket(s); return true; } @@ -3104,7 +3104,7 @@ class ServernameResolver : public Resolver TreeServer* CheckDupe = FindServer(MyLink.Name.c_str()); if (!CheckDupe) /* Check that nobody tried to connect it successfully while we were resolving */ { - TreeSocket* newsocket = new TreeSocket(result,MyLink.Port,false,10,MyLink.Name.c_str()); + TreeSocket* newsocket = new TreeSocket(ServerInstance, result,MyLink.Port,false,10,MyLink.Name.c_str()); if (newsocket->GetFd() > -1) { /* We're all OK */ @@ -3334,7 +3334,7 @@ void ReadConfiguration(bool rebind) { IP = ""; } - TreeSocket* listener = new TreeSocket(IP.c_str(),Port,true,10); + TreeSocket* listener = new TreeSocket(ServerInstance, IP.c_str(),Port,true,10); if (listener->GetState() == I_LISTENING) { Srv->AddSocket(listener); @@ -3781,7 +3781,7 @@ class ModuleSpanningTree : public Module /* Do we already have an IP? If so, no need to resolve it. */ if (insp_aton(x->IPAddr.c_str(), &binip) > 0) { - TreeSocket* newsocket = new TreeSocket(x->IPAddr,x->Port,false,10,x->Name.c_str()); + TreeSocket* newsocket = new TreeSocket(ServerInstance, x->IPAddr,x->Port,false,10,x->Name.c_str()); if (newsocket->GetFd() > -1) { Srv->AddSocket(newsocket); @@ -3862,7 +3862,7 @@ class ModuleSpanningTree : public Module /* Do we already have an IP? If so, no need to resolve it. */ if (insp_aton(x->IPAddr.c_str(), &binip) > 0) { - TreeSocket* newsocket = new TreeSocket(x->IPAddr,x->Port,false,10,x->Name.c_str()); + TreeSocket* newsocket = new TreeSocket(ServerInstance,x->IPAddr,x->Port,false,10,x->Name.c_str()); if (newsocket->GetFd() > -1) { Srv->AddSocket(newsocket); diff --git a/src/userprocess.cpp b/src/userprocess.cpp index d262b5cab..7d4ce9442 100644 --- a/src/userprocess.cpp +++ b/src/userprocess.cpp @@ -56,12 +56,9 @@ extern struct sockaddr_in client,server; extern socklen_t length; extern std::vector<Module*> modules; extern std::vector<ircd_module*> factory; -extern std::vector<InspSocket*> module_sockets; extern time_t TIME; extern time_t OLDTIME; extern std::vector<userrec*> local_users; -extern InspSocket* socket_ref[MAX_DESCRIPTORS]; - extern InspIRCd* ServerInstance; extern userrec* fd_ref_table[MAX_DESCRIPTORS]; char data[65536]; @@ -280,26 +277,26 @@ void ProcessUser(userrec* cu) } } -void DoSocketTimeouts(time_t TIME) +void DoSocketTimeouts(time_t TIME, InspIRCd* SI) { - unsigned int numsockets = module_sockets.size(); - SocketEngine* SE = ServerInstance->SE; + unsigned int numsockets = SI->module_sockets.size(); + SocketEngine* SE = SI->SE; - for (std::vector<InspSocket*>::iterator a = module_sockets.begin(); a < module_sockets.end(); a++) + for (std::vector<InspSocket*>::iterator a = SI->module_sockets.begin(); a < SI->module_sockets.end(); a++) { InspSocket* s = (InspSocket*)*a; - if ((s) && (s->GetFd() >= 0) && (s->GetFd() < MAX_DESCRIPTORS) && (socket_ref[s->GetFd()] != NULL) && (s->Timeout(TIME))) + if ((s) && (s->GetFd() >= 0) && (s->GetFd() < MAX_DESCRIPTORS) && (SI->socket_ref[s->GetFd()] != NULL) && (s->Timeout(TIME))) { log(DEBUG,"userprocess.cpp: Socket poll returned false, close and bail"); - socket_ref[s->GetFd()] = NULL; + SI->socket_ref[s->GetFd()] = NULL; SE->DelFd(s->GetFd()); - module_sockets.erase(a); + SI->module_sockets.erase(a); s->Close(); DELETE(s); break; } - if (module_sockets.size() != numsockets) + if (SI->module_sockets.size() != numsockets) break; } } |