summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdam <Adam@anope.org>2013-09-16 06:28:48 -0400
committerAdam <Adam@anope.org>2013-09-16 06:47:42 -0400
commite3c05efe5e5085f3db14f1532a92de460b899ab5 (patch)
treea486474c1eff7e04a7167c1d069d23a93406e171 /src
parent8cbaf7e9904e3cc6aca22566c83ea25959357d48 (diff)
Remove static variables from functions in modules which causes them to be marked as gnu unique objects, which breaks dlclose()/dlopen() on g++ 4.5+
Diffstat (limited to 'src')
-rw-r--r--src/modulemanager.cpp29
1 files changed, 8 insertions, 21 deletions
diff --git a/src/modulemanager.cpp b/src/modulemanager.cpp
index a4df9004c..5b22e9419 100644
--- a/src/modulemanager.cpp
+++ b/src/modulemanager.cpp
@@ -22,7 +22,7 @@
#endif
std::list<Module *> ModuleManager::Modules;
-std::map<Anope::string, std::vector<Module *> > ModuleManager::EventHandlers;
+std::vector<Module *> ModuleManager::EventHandlers[I_SIZE];
#ifdef _WIN32
void ModuleManager::CleanupRuntimeDirectory()
@@ -112,19 +112,6 @@ static ModuleReturn moduleCopyFile(const Anope::string &name, Anope::string &out
}
#endif
-std::vector<Module *> &ModuleManager::GetEventHandlers(const Anope::string &name)
-{
- std::map<Anope::string, std::vector<Module *> >::iterator it = EventHandlers.find(name);
- if (it != EventHandlers.end())
- return it->second;
-
- std::vector<Module *> &modules = EventHandlers[name];
- /* Populate initial vector */
- std::copy(Modules.begin(), Modules.end(), std::back_inserter(modules));
-
- return modules;
-}
-
/* This code was found online at http://www.linuxjournal.com/article/3687#comment-26593
*
* This function will take a pointer from either dlsym or GetProcAddress and cast it in
@@ -263,8 +250,8 @@ ModuleReturn ModuleManager::LoadModule(const Anope::string &modname, User *u)
Log(LOG_DEBUG) << "Module " << modname << " loaded.";
/* Attach module to all events */
- for (std::map<Anope::string, std::vector<Module *> >::iterator it = EventHandlers.begin(); it != EventHandlers.end(); ++it)
- it->second.push_back(m);
+ for (unsigned i = 0; i < I_SIZE; ++i)
+ EventHandlers[i].push_back(m);
FOREACH_MOD(OnModuleLoad, (u, m));
@@ -365,9 +352,9 @@ ModuleReturn ModuleManager::DeleteModule(Module *m)
void ModuleManager::DetachAll(Module *mod)
{
- for (std::map<Anope::string, std::vector<Module *> >::iterator it = EventHandlers.begin(); it != EventHandlers.end(); ++it)
+ for (unsigned i = 0; i < I_SIZE; ++i)
{
- std::vector<Module *> &mods = it->second;
+ std::vector<Module *> &mods = EventHandlers[i];
std::vector<Module *>::iterator it2 = std::find(mods.begin(), mods.end(), mod);
if (it2 != mods.end())
mods.erase(it2);
@@ -376,13 +363,13 @@ void ModuleManager::DetachAll(Module *mod)
bool ModuleManager::SetPriority(Module *mod, Priority s)
{
- for (std::map<Anope::string, std::vector<Module *> >::iterator it = EventHandlers.begin(); it != EventHandlers.end(); ++it)
- SetPriority(mod, it->first, s);
+ for (unsigned i = 0; i < I_SIZE; ++i)
+ SetPriority(mod, static_cast<Implementation>(i), s);
return true;
}
-bool ModuleManager::SetPriority(Module *mod, const Anope::string &i, Priority s, Module **modules, size_t sz)
+bool ModuleManager::SetPriority(Module *mod, Implementation i, Priority s, Module **modules, size_t sz)
{
/** To change the priority of a module, we first find its position in the vector,
* then we find the position of the other modules in the vector that this module