X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Finspircd.cpp;h=b806776c283c65904af143dd078fdce4d3910dc1;hb=c2906e93be35abeea3e652273a7ff1928db8aae3;hp=30ff72c411a8080e9a7ea915ea8fbdb32fdef447;hpb=d5423812506f7017c7bc3a5cadedd2c793dcb378;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 30ff72c41..b806776c2 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -492,35 +492,44 @@ 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!"); + } + 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()); return false; - } + } #ifndef STATIC_LINK } else @@ -628,14 +637,14 @@ int InspIRCd::Run() * timing using this event, so we dont have to * time this exactly). */ - if (((TIME % 8) == 0) && (!expire_run)) + if (((TIME % 5) == 0) && (!expire_run)) { expire_lines(); FOREACH_MOD(I_OnBackgroundTimer,OnBackgroundTimer(TIME)); expire_run = true; continue; } - else if ((TIME % 8) == 1) + else if ((TIME % 5) == 1) { expire_run = false; } @@ -742,7 +751,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);