summaryrefslogtreecommitdiff
path: root/src/modmanager_static.cpp
diff options
context:
space:
mode:
authordanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2010-01-17 16:00:14 +0000
committerdanieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7>2010-01-17 16:00:14 +0000
commit4b6bdeccb537b6f8030172c37afa7dc324e26765 (patch)
tree9c165894ba0a62072f81630fbba789770f2b63ba /src/modmanager_static.cpp
parent92974819e3bf1c3a97b83f6f4ccc612283120794 (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/modmanager_static.cpp')
-rw-r--r--src/modmanager_static.cpp14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/modmanager_static.cpp b/src/modmanager_static.cpp
index 322703679..e267a2c90 100644
--- a/src/modmanager_static.cpp
+++ b/src/modmanager_static.cpp
@@ -64,15 +64,20 @@ bool ModuleManager::Load(const char* name)
{
if ((**i).name == name)
{
+ Module* c = NULL;
try
{
- Module* c = (*(**i).init)();
+ c = (*(**i).init)();
Modules[name] = c;
+ c->init();
FOREACH_MOD(I_OnLoadModule,OnLoadModule(c));
return true;
}
catch (CoreException& modexcept)
{
+ if (c)
+ DoSafeUnload(c);
+ delete c;
ServerInstance->Logs->Log("MODULE", DEFAULT, "Unable to load " + (**i).name + ": " + modexcept.GetReason());
}
}
@@ -117,15 +122,20 @@ void ModuleManager::LoadAll()
ModCount = 0;
for(std::vector<AllModuleList*>::iterator i = modlist->begin(); i != modlist->end(); ++i)
{
+ Module* c = NULL;
try
{
- Module* c = (*(**i).init)();
+ c = (*(**i).init)();
c->ModuleSourceFile = (**i).name;
Modules[(**i).name] = c;
+ c->init();
FOREACH_MOD(I_OnLoadModule,OnLoadModule(c));
}
catch (CoreException& modexcept)
{
+ if (c)
+ DoSafeUnload(c);
+ delete c;
ServerInstance->Logs->Log("MODULE", DEFAULT, "Unable to load " + (**i).name + ": " + modexcept.GetReason());
}
}