summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/modules/extra/m_mysql.cpp75
-rw-r--r--src/modules/extra/m_pgsql.cpp25
-rw-r--r--src/modules/extra/m_sqlauth.cpp31
-rw-r--r--src/modules/extra/m_sqloper.cpp37
-rw-r--r--src/modules/extra/m_sqlutils.cpp14
5 files changed, 97 insertions, 85 deletions
diff --git a/src/modules/extra/m_mysql.cpp b/src/modules/extra/m_mysql.cpp
index 63ed7d540..2449b5238 100644
--- a/src/modules/extra/m_mysql.cpp
+++ b/src/modules/extra/m_mysql.cpp
@@ -725,6 +725,47 @@ class ModuleSQL : public Module
pthread_t Dispatcher;
int currid;
+ ModuleSQL(InspIRCd* Me)
+ : Module::Module(Me)
+ {
+ ServerInstance->UseInterface("SQLutils");
+
+ Conf = new ConfigReader(ServerInstance);
+ PublicServerInstance = ServerInstance;
+ currid = 0;
+ SQLModule = this;
+
+ MessagePipe = new Notifier(ServerInstance);
+ ServerInstance->Log(DEBUG,"Bound notifier to 127.0.0.1:%d",MessagePipe->GetPort());
+
+ pthread_attr_t attribs;
+ pthread_attr_init(&attribs);
+ pthread_attr_setdetachstate(&attribs, PTHREAD_CREATE_DETACHED);
+ if (pthread_create(&this->Dispatcher, &attribs, DispatcherThread, (void *)this) != 0)
+ {
+ throw ModuleException("m_mysql: Failed to create dispatcher thread: " + std::string(strerror(errno)));
+ }
+
+ if (!ServerInstance->PublishFeature("SQL", this))
+ {
+ /* Tell worker thread to exit NOW */
+ giveup = true;
+ throw ModuleException("m_mysql: Unable to publish feature 'SQL'");
+ }
+
+ ServerInstance->PublishInterface("SQL", this);
+ }
+
+ virtual ~ModuleSQL()
+ {
+ giveup = true;
+ ClearDatabases();
+ DELETE(Conf);
+ ServerInstance->UnpublishInterface("SQL", this);
+ ServerInstance->DoneWithInterface("SQLutils");
+ }
+
+
void Implements(char* List)
{
List[I_OnRehash] = List[I_OnRequest] = 1;
@@ -774,40 +815,6 @@ class ModuleSQL : public Module
return NULL;
}
- ModuleSQL(InspIRCd* Me)
- : Module::Module(Me)
- {
-
- Conf = new ConfigReader(ServerInstance);
- PublicServerInstance = ServerInstance;
- currid = 0;
- SQLModule = this;
-
- MessagePipe = new Notifier(ServerInstance);
- ServerInstance->Log(DEBUG,"Bound notifier to 127.0.0.1:%d",MessagePipe->GetPort());
-
- pthread_attr_t attribs;
- pthread_attr_init(&attribs);
- pthread_attr_setdetachstate(&attribs, PTHREAD_CREATE_DETACHED);
- if (pthread_create(&this->Dispatcher, &attribs, DispatcherThread, (void *)this) != 0)
- {
- throw ModuleException("m_mysql: Failed to create dispatcher thread: " + std::string(strerror(errno)));
- }
- if (!ServerInstance->PublishFeature("SQL", this))
- {
- /* Tell worker thread to exit NOW */
- giveup = true;
- throw ModuleException("m_mysql: Unable to publish feature 'SQL'");
- }
- }
-
- virtual ~ModuleSQL()
- {
- giveup = true;
- ClearDatabases();
- DELETE(Conf);
- }
-
virtual void OnRehash(const std::string &parameter)
{
/* TODO: set rehash bool here, which makes the dispatcher thread rehash at next opportunity */
diff --git a/src/modules/extra/m_pgsql.cpp b/src/modules/extra/m_pgsql.cpp
index 7e782c277..dedb6a2c3 100644
--- a/src/modules/extra/m_pgsql.cpp
+++ b/src/modules/extra/m_pgsql.cpp
@@ -518,15 +518,30 @@ public:
ModulePgSQL(InspIRCd* Me)
: Module::Module(Me), currid(0)
{
- ServerInstance->Log(DEBUG, "%s 'SQL' feature", ServerInstance->PublishFeature("SQL", this) ? "Published" : "Couldn't publish");
-
+ ServerInstance->UseInterface("SQLutils");
+
sqlsuccess = new char[strlen(SQLSUCCESS)+1];
strlcpy(sqlsuccess, SQLSUCCESS, strlen(SQLSUCCESS)+1);
+ if (!ServerInstance->PublishFeature("SQL", this))
+ {
+ throw ModuleException("m_pgsql: Unable to publish feature 'SQL'");
+ }
+
OnRehash("");
+
+ ServerInstance->PublishInterface("SQL", this);
}
+ virtual ~ModulePgSQL()
+ {
+ DELETE(sqlsuccess);
+ ServerInstance->UnpublishInterface("SQL", this);
+ ServerInstance->DoneWithInterface("SQLutils");
+ }
+
+
void Implements(char* List)
{
List[I_OnUnloadModule] = List[I_OnRequest] = List[I_OnRehash] = List[I_OnUserRegister] = List[I_OnCheckReady] = List[I_OnUserDisconnect] = 1;
@@ -658,11 +673,7 @@ public:
{
return Version(1, 1, 0, 0, VF_VENDOR|VF_SERVICEPROVIDER, API_VERSION);
}
-
- virtual ~ModulePgSQL()
- {
- DELETE(sqlsuccess);
- }
+
};
SQLConn::SQLConn(InspIRCd* SI, ModulePgSQL* self, const SQLhost& hi)
diff --git a/src/modules/extra/m_sqlauth.cpp b/src/modules/extra/m_sqlauth.cpp
index 8b02bed69..b2b7c9044 100644
--- a/src/modules/extra/m_sqlauth.cpp
+++ b/src/modules/extra/m_sqlauth.cpp
@@ -12,7 +12,6 @@
*/
#include <string>
-
#include "users.h"
#include "channels.h"
#include "modules.h"
@@ -28,6 +27,7 @@ class ModuleSQLAuth : public Module
{
InspIRCd* Srv;
Module* SQLutils;
+ Module* SQLprovider;
std::string usertable;
std::string userfield;
@@ -43,21 +43,22 @@ public:
ModuleSQLAuth(InspIRCd* Me)
: Module::Module(Me), Srv(Me)
{
- SQLutils = Srv->FindFeature("SQLutils");
-
- if(SQLutils)
- {
- ServerInstance->Log(DEBUG, "Successfully got SQLutils pointer");
- }
- else
- {
- ServerInstance->Log(DEFAULT, "ERROR: This module requires a module offering the 'SQLutils' feature (usually m_sqlutils.so). Please load it and try again.");
- throw ModuleException("This module requires a module offering the 'SQLutils' feature (usually m_sqlutils.so). Please load it and try again.");
- }
-
+ ServerInstance->UseInterface("SQLutils");
+ ServerInstance->UseInterface("SQL");
+
+ SQLutils = ServerInstance->FindModule("m_sqlutils.so");
+ if (!SQLutils)
+ throw ModuleException("Can't find m_sqlutils.so. Please load m_sqlutils.so before m_sqlauth.so.");
+
OnRehash("");
}
+ virtual ~ModuleSQLAuth()
+ {
+ ServerInstance->DoneWithInterface("SQL");
+ ServerInstance->DoneWithInterface("SQLutils");
+ }
+
void Implements(char* List)
{
List[I_OnUserDisconnect] = List[I_OnCheckReady] = List[I_OnRequest] = List[I_OnRehash] = List[I_OnUserRegister] = 1;
@@ -210,10 +211,6 @@ public:
return user->GetExt("sqlauthed");
}
- virtual ~ModuleSQLAuth()
- {
- }
-
virtual Version GetVersion()
{
return Version(1,1,1,0,VF_VENDOR,API_VERSION);
diff --git a/src/modules/extra/m_sqloper.cpp b/src/modules/extra/m_sqloper.cpp
index f548c15ee..b7a45af45 100644
--- a/src/modules/extra/m_sqloper.cpp
+++ b/src/modules/extra/m_sqloper.cpp
@@ -35,26 +35,20 @@ public:
ModuleSQLOper(InspIRCd* Me)
: Module::Module(Me), Srv(Me)
{
- SQLutils = Srv->FindFeature("SQLutils");
-
- if (SQLutils)
- {
- ServerInstance->Log(DEBUG, "Successfully got SQLutils pointer");
- }
- else
- {
- ServerInstance->Log(DEFAULT, "ERROR: This module requires a module offering the 'SQLutils' feature (usually m_sqlutils.so). Please load it and try again.");
- throw ModuleException("This module requires a module offering the 'SQLutils' feature (usually m_sqlutils.so). Please load it and try again.");
- }
-
+ ServerInstance->UseInterface("SQLutils");
+ ServerInstance->UseInterface("SQL");
+
+ SQLutils = ServerInstance->FindModule("m_sqlutils.so");
+ if (!SQLutils)
+ throw ModuleException("Can't find m_sqlutils.so. Please load m_sqlutils.so before m_sqloper.so.");
+
OnRehash("");
}
- virtual void OnRehash(const std::string &parameter)
+ virtual ~ModuleSQLOper()
{
- ConfigReader Conf(Srv);
-
- databaseid = Conf.ReadValue("sqloper", "dbid", 0); /* Database ID of a database configured for the service provider module */
+ ServerInstance->DoneWithInterface("SQL");
+ ServerInstance->DoneWithInterface("SQLutils");
}
void Implements(char* List)
@@ -62,6 +56,13 @@ public:
List[I_OnRequest] = List[I_OnRehash] = List[I_OnPreCommand] = 1;
}
+ virtual void OnRehash(const std::string &parameter)
+ {
+ ConfigReader Conf(Srv);
+
+ databaseid = Conf.ReadValue("sqloper", "dbid", 0); /* Database ID of a database configured for the service provider module */
+ }
+
virtual int OnPreCommand(const std::string &command, const char** parameters, int pcnt, userrec *user, bool validated, const std::string &original_line)
{
if ((validated) && (command == "OPER"))
@@ -272,10 +273,6 @@ public:
return false;
}
- virtual ~ModuleSQLOper()
- {
- }
-
virtual Version GetVersion()
{
return Version(1,1,1,0,VF_VENDOR,API_VERSION);
diff --git a/src/modules/extra/m_sqlutils.cpp b/src/modules/extra/m_sqlutils.cpp
index c423246cc..bec8a4450 100644
--- a/src/modules/extra/m_sqlutils.cpp
+++ b/src/modules/extra/m_sqlutils.cpp
@@ -35,8 +35,6 @@ typedef std::list<unsigned long> AssocIdList;
class ModuleSQLutils : public Module
{
private:
-
-
IdUserMap iduser;
IdChanMap idchan;
@@ -44,9 +42,14 @@ public:
ModuleSQLutils(InspIRCd* Me)
: Module::Module(Me)
{
- ServerInstance->Log(DEBUG, "%s 'SQLutils' feature", ServerInstance->PublishFeature("SQLutils", this) ? "Published" : "Couldn't publish");
+ ServerInstance->PublishInterface("SQLutils", this);
}
+ virtual ~ModuleSQLutils()
+ {
+ ServerInstance->UnpublishInterface("SQLutils", this);
+ }
+
void Implements(char* List)
{
List[I_OnChannelDelete] = List[I_OnUnloadModule] = List[I_OnRequest] = List[I_OnUserDisconnect] = 1;
@@ -263,12 +266,9 @@ public:
virtual Version GetVersion()
{
- return Version(1, 1, 0, 0, VF_STATIC|VF_VENDOR|VF_SERVICEPROVIDER, API_VERSION);
+ return Version(1, 1, 0, 0, VF_VENDOR|VF_SERVICEPROVIDER, API_VERSION);
}
- virtual ~ModuleSQLutils()
- {
- }
};
class ModuleSQLutilsFactory : public ModuleFactory