summaryrefslogtreecommitdiff
path: root/src/modules
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-08-09 14:53:19 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-08-09 14:53:19 +0000
commitab46b96db4d457e6a4f2e978c38b79762cdeb9d5 (patch)
tree01b9489ae9804ee45b765ad7045efee54b34347b /src/modules
parentf0680338833dd76966ba1769980abb9eafb50467 (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
Diffstat (limited to 'src/modules')
-rw-r--r--src/modules/extra/m_mysql.cpp10
-rw-r--r--src/modules/extra/m_pgsql.cpp11
-rw-r--r--src/modules/m_httpd.cpp10
-rw-r--r--src/modules/m_ident.cpp6
-rw-r--r--src/modules/m_spanningtree.cpp22
5 files changed, 31 insertions, 28 deletions
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);