summaryrefslogtreecommitdiff
path: root/src/modules/extra/m_mysql.cpp
diff options
context:
space:
mode:
authorpeavey <peavey@e03df62e-2008-0410-955e-edbf42e46eb7>2006-12-28 22:42:38 +0000
committerpeavey <peavey@e03df62e-2008-0410-955e-edbf42e46eb7>2006-12-28 22:42:38 +0000
commit59bd18f2a0b43b71ee32124add9d40d1d3a54919 (patch)
tree2e498ff5e90f890c10a73a38e6d1d3901eb4cc4a /src/modules/extra/m_mysql.cpp
parent5dce8782ebea6cfa0525a46819641737214d47d9 (diff)
Change the SQLutils and SQL providers to also use interfaces for proper unload order, taking away the need for a static m_sqlutils. Depend order: m_sqlutils -> sql providers (m_mysql m_pgsql) -> sql modules (m_sqlauth m_sqloper).
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6149 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules/extra/m_mysql.cpp')
-rw-r--r--src/modules/extra/m_mysql.cpp75
1 files changed, 41 insertions, 34 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 */