From 4b6bdeccb537b6f8030172c37afa7dc324e26765 Mon Sep 17 00:00:00 2001 From: danieldg Date: Sun, 17 Jan 2010 16:00:14 +0000 Subject: 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 --- src/modules.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) (limited to 'src/modules.cpp') 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: -- cgit v1.2.3