summaryrefslogtreecommitdiff
path: root/src/inspircd.cpp
diff options
context:
space:
mode:
authorbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-02-19 14:44:32 +0000
committerbrain <brain@e03df62e-2008-0410-955e-edbf42e46eb7>2006-02-19 14:44:32 +0000
commit2a9b0cdd30113ab4926f4b68350d619c015c89a3 (patch)
treec756e270ca7d938d62d09c2ecee9d7c6be34af50 /src/inspircd.cpp
parent45fa01dc79889c68734a7629e8487917cf26a836 (diff)
Added exception handling for module loading
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3240 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/inspircd.cpp')
-rw-r--r--src/inspircd.cpp67
1 files changed, 41 insertions, 26 deletions
diff --git a/src/inspircd.cpp b/src/inspircd.cpp
index 30ff72c41..de9f64781 100644
--- a/src/inspircd.cpp
+++ b/src/inspircd.cpp
@@ -492,35 +492,43 @@ bool InspIRCd::LoadModule(const char* filename)
snprintf(MODERR,MAXBUF,"Loader/Linker error: %s",factory[MODCOUNT+1]->LastError());
return false;
}
- if (factory[MODCOUNT+1]->factory)
- {
- Module* m = factory[MODCOUNT+1]->factory->CreateModule(MyServer);
- modules[MODCOUNT+1] = m;
- /* save the module and the module's classfactory, if
- * this isnt done, random crashes can occur :/ */
- Config->module_names.push_back(filename);
-
- char* x = &Config->implement_lists[MODCOUNT+1][0];
- for(int t = 0; t < 255; t++)
- x[t] = 0;
+ try
+ {
+ if (factory[MODCOUNT+1]->factory)
+ {
+ Module* m = factory[MODCOUNT+1]->factory->CreateModule(MyServer);
+ modules[MODCOUNT+1] = m;
+ /* save the module and the module's classfactory, if
+ * this isnt done, random crashes can occur :/ */
+ Config->module_names.push_back(filename);
+
+ char* x = &Config->implement_lists[MODCOUNT+1][0];
+ for(int t = 0; t < 255; t++)
+ x[t] = 0;
- modules[MODCOUNT+1]->Implements(x);
+ modules[MODCOUNT+1]->Implements(x);
- for(int t = 0; t < 255; t++)
- {
- Config->global_implementation[t] += Config->implement_lists[MODCOUNT+1][t];
- if (Config->implement_lists[MODCOUNT+1][t])
+ for(int t = 0; t < 255; t++)
{
- log(DEBUG,"Add global implementation: %d %d => %d",MODCOUNT+1,t,Config->global_implementation[t]);
+ Config->global_implementation[t] += Config->implement_lists[MODCOUNT+1][t];
+ if (Config->implement_lists[MODCOUNT+1][t])
+ {
+ log(DEBUG,"Add global implementation: %d %d => %d",MODCOUNT+1,t,Config->global_implementation[t]);
+ }
}
- }
- }
- else
- {
- log(DEFAULT,"Unable to load %s",modfile);
- snprintf(MODERR,MAXBUF,"Factory function failed!");
- return false;
- }
+ }
+ else
+ {
+ log(DEFAULT,"Unable to load %s",modfile);
+ snprintf(MODERR,MAXBUF,"Factory function failed!");
+ return false;
+ }
+ }
+ catch (ModuleException modexcept)
+ {
+ log(DEFAULT,"Unable to load %s: ",modfile,modexcept.GetReason());
+ snprintf(MODERR,MAXBUF,"Factory function threw an exception: %s",modexcept.GetReason());
+ }
#ifndef STATIC_LINK
}
else
@@ -742,7 +750,14 @@ int InspIRCd::Run()
NonBlocking(incomingSockfd);
if (Config->GetIOHook(in_port))
{
- Config->GetIOHook(in_port)->OnRawSocketAccept(incomingSockfd, (char*)inet_ntoa(client.sin_addr), in_port);
+ try
+ {
+ Config->GetIOHook(in_port)->OnRawSocketAccept(incomingSockfd, (char*)inet_ntoa(client.sin_addr), in_port);
+ }
+ catch (ModuleException modexcept)
+ {
+ log(DEBUG,"Module exception cought: %s",modexcept.GetReason()); \
+ }
}
stats->statsAccept++;
AddClient(incomingSockfd, in_port, false, client.sin_addr);