diff options
author | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2010-01-17 16:00:14 +0000 |
---|---|---|
committer | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2010-01-17 16:00:14 +0000 |
commit | 4b6bdeccb537b6f8030172c37afa7dc324e26765 (patch) | |
tree | 9c165894ba0a62072f81630fbba789770f2b63ba /src/modules.cpp | |
parent | 92974819e3bf1c3a97b83f6f4ccc612283120794 (diff) |
Add Module::init() for correct exception handling during hook registration
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@12278 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/modules.cpp')
-rw-r--r-- | src/modules.cpp | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/src/modules.cpp b/src/modules.cpp index b25469c30..22628ff0f 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -174,6 +174,9 @@ ModuleManager::~ModuleManager() bool ModuleManager::Attach(Implementation i, Module* mod) { + if (Modules.find(mod->ModuleSourceFile) == Modules.end()) + ServerInstance->Logs->Log("MODULE", ERROR, "Module %s is attaching to hook %d in constructor; this does not handle exceptions correctly!", mod->ModuleSourceFile.c_str(), i); + if (std::find(EventHandlers[i].begin(), EventHandlers[i].end(), mod) != EventHandlers[i].end()) return false; @@ -417,16 +420,12 @@ bool InspIRCd::IsValidModuleCommand(const std::string &commandname, int pcnt, Us return this->Parser->IsValidCommand(commandname, pcnt, user); } -void InspIRCd::AddCommand(Command *f) -{ - if (!this->Parser->AddCommand(f)) - { - throw ModuleException("Command "+std::string(f->name)+" already exists."); - } -} - void ModuleManager::AddService(ServiceProvider& item) { + Module* owner = item.creator; + if (Modules.find(owner->ModuleSourceFile) == Modules.end()) + ServerInstance->Logs->Log("MODULE", ERROR, "Module %s is registering item %s in constructor; this does not handle exceptions correctly!", owner->ModuleSourceFile.c_str(), item.name.c_str()); + switch (item.service) { case SERVICE_COMMAND: |