summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/modules.h6
-rw-r--r--modules/core/os_modlist.cpp2
-rw-r--r--modules/extra/db_mysql.cpp2
-rw-r--r--modules/extra/m_mysql.cpp8
-rw-r--r--src/main.cpp8
-rw-r--r--src/modulemanager.cpp14
6 files changed, 22 insertions, 18 deletions
diff --git a/include/modules.h b/include/modules.h
index 307c83d87..51581438c 100644
--- a/include/modules.h
+++ b/include/modules.h
@@ -152,7 +152,8 @@ enum ModuleReturn
/** Priority types which can be returned from Module::Prioritize()
*/
enum Priority { PRIORITY_FIRST, PRIORITY_DONTCARE, PRIORITY_LAST, PRIORITY_BEFORE, PRIORITY_AFTER };
-enum MODType { CORE, PROTOCOL, THIRD, SUPPORTED, QATESTED, ENCRYPTION, DATABASE, SOCKETENGINE };
+/* Module types, in the order in which they are unloaded. The order these are in is IMPORTANT */
+enum MODType { MT_BEGIN, THIRD, QATESTED, SUPPORTED, CORE, DATABASE, ENCRYPTION, PROTOCOL, SOCKETENGINE, MT_END };
struct Message;
typedef std::multimap<Anope::string, Message *> message_map;
@@ -1200,9 +1201,8 @@ class CoreExport ModuleManager
/** Unloading all modules, NEVER call this when Anope isn't shutting down.
* Ever.
- * @param unload_proto true to unload the protocol module
*/
- static void UnloadAll(bool unload_proto);
+ static void UnloadAll();
/** Register a service
* @param s The service
diff --git a/modules/core/os_modlist.cpp b/modules/core/os_modlist.cpp
index bdd7d3f19..58cd2d6c6 100644
--- a/modules/core/os_modlist.cpp
+++ b/modules/core/os_modlist.cpp
@@ -193,6 +193,8 @@ class CommandOSModList : public Command
++count;
}
break;
+ default:
+ break;
}
}
if (!count)
diff --git a/modules/extra/db_mysql.cpp b/modules/extra/db_mysql.cpp
index 7bc48230f..27a1226d1 100644
--- a/modules/extra/db_mysql.cpp
+++ b/modules/extra/db_mysql.cpp
@@ -365,6 +365,8 @@ class DBMySQL : public Module
{
me = this;
+ this->SetType(DATABASE);
+
this->lastwarn = 0;
this->ro = false;
diff --git a/modules/extra/m_mysql.cpp b/modules/extra/m_mysql.cpp
index 72176fa70..176899a1b 100644
--- a/modules/extra/m_mysql.cpp
+++ b/modules/extra/m_mysql.cpp
@@ -187,8 +187,7 @@ class ModuleSQL : public Module
DThread->Wakeup();
DThread->Join();
- if (SocketEngine)
- delete SQLPipe;
+ delete SQLPipe;
}
void OnReload(bool startup)
@@ -278,9 +277,10 @@ MySQLService::MySQLService(Module *o, const Anope::string &n, const Anope::strin
MySQLService::~MySQLService()
{
+ me->DThread->Lock();
this->Lock.Lock();
- this->Lock.Unlock();
mysql_close(this->sql);
+ this->sql = NULL;
for (unsigned i = me->QueryRequests.size(); i > 0; --i)
{
@@ -293,6 +293,8 @@ MySQLService::~MySQLService()
me->QueryRequests.erase(me->QueryRequests.begin() + i);
}
}
+ this->Lock.Unlock();
+ me->DThread->Unlock();
}
void MySQLService::Run(SQLInterface *i, const Anope::string &query)
diff --git a/src/main.cpp b/src/main.cpp
index 8132e9d1c..df7c61c63 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -189,9 +189,7 @@ void do_restart_services()
SocketEngine->Process();
delete UplinkSock;
close_log();
- /* First don't unload protocol module, then do so */
- ModuleManager::UnloadAll(false);
- ModuleManager::UnloadAll(true);
+ ModuleManager::UnloadAll();
chdir(binary_dir.c_str());
execve(services_bin.c_str(), my_av, my_envp);
if (!readonly)
@@ -238,9 +236,7 @@ static void services_shutdown()
SocketEngine->Process();
delete UplinkSock;
FOREACH_MOD(I_OnShutdown, OnShutdown());
- /* First don't unload protocol module, then do so */
- ModuleManager::UnloadAll(false);
- ModuleManager::UnloadAll(true);
+ ModuleManager::UnloadAll();
/* just in case they weren't all removed at least run once */
ModuleRunTimeDirCleanUp();
}
diff --git a/src/modulemanager.cpp b/src/modulemanager.cpp
index b5f0d51f2..f539f273d 100644
--- a/src/modulemanager.cpp
+++ b/src/modulemanager.cpp
@@ -419,16 +419,18 @@ void ModuleManager::ClearCallBacks(Module *m)
/** Unloading all modules, NEVER call this when Anope isn't shutting down.
* Ever.
- * @param unload_proto true to unload the protocol module
*/
-void ModuleManager::UnloadAll(bool unload_proto)
+void ModuleManager::UnloadAll()
{
- for (std::list<Module *>::iterator it = Modules.begin(), it_end = Modules.end(); it != it_end; )
+ for (size_t i = MT_BEGIN + 1; i != MT_END; ++i)
{
- Module *m = *it++;
+ for (std::list<Module *>::iterator it = Modules.begin(), it_end = Modules.end(); it != it_end; )
+ {
+ Module *m = *it++;
- if (unload_proto || m->type != PROTOCOL)
- DeleteModule(m);
+ if (static_cast<MODType>(i) == m->type)
+ DeleteModule(m);
+ }
}
}