X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodmanager_dynamic.cpp;h=050f41c758379e7581fea0054287a3532d885c7e;hb=a785f350fd584d87f3b84bbaff569ecb59c29f04;hp=27da56c692ab32f9a779403563d02b7d9082b9b6;hpb=78a6d62732f2f0c2752d9de8729a745413ebe64a;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modmanager_dynamic.cpp b/src/modmanager_dynamic.cpp index 27da56c69..050f41c75 100644 --- a/src/modmanager_dynamic.cpp +++ b/src/modmanager_dynamic.cpp @@ -36,7 +36,10 @@ bool ModuleManager::Load(const std::string& filename, bool defer) { /* Don't allow people to specify paths for modules, it doesn't work as expected */ if (filename.find('/') != std::string::npos) + { + LastModuleError = "You can't load modules with a path: " + filename; return false; + } char modfile[MAXBUF]; snprintf(modfile,MAXBUF,"%s/%s",ServerInstance->Config->ModPath.c_str(),filename.c_str()); @@ -66,6 +69,7 @@ bool ModuleManager::Load(const std::string& filename, bool defer) { newmod->ModuleSourceFile = filename; newmod->ModuleDLLManager = newhandle; + newmod->dying = false; Modules[filename] = newmod; std::string version = newhandle->GetVersion(); if (defer) @@ -94,7 +98,10 @@ bool ModuleManager::Load(const std::string& filename, bool defer) { // failure in module constructor if (newmod) + { DoSafeUnload(newmod); + ServerInstance->GlobalCulls.AddItem(newhandle); + } else delete newhandle; LastModuleError = "Unable to load " + filename + ": " + modexcept.GetReason(); @@ -175,7 +182,7 @@ void ModuleManager::Reload(Module* mod, HandlerBase1* callback) { if (CanUnload(mod)) ServerInstance->AtomicActions.AddAction(new ReloadAction(mod, callback)); - else + else if (callback) callback->Call(false); } @@ -201,7 +208,7 @@ void ModuleManager::LoadAll() if (!Load(entry->d_name, true)) { ServerInstance->Logs->Log("MODULE", DEFAULT, this->LastError()); - std::cout << std::endl << "[" << con_red << "*" << con_reset << "]" << this->LastError() << std::endl << std::endl; + std::cout << std::endl << "[" << con_red << "*" << con_reset << "] " << this->LastError() << std::endl << std::endl; ServerInstance->Exit(EXIT_STATUS_MODULE); } } @@ -220,7 +227,7 @@ void ModuleManager::LoadAll() if (!this->Load(name, true)) { ServerInstance->Logs->Log("MODULE", DEFAULT, this->LastError()); - std::cout << std::endl << "[" << con_red << "*" << con_reset << "]" << this->LastError() << std::endl << std::endl; + std::cout << std::endl << "[" << con_red << "*" << con_reset << "] " << this->LastError() << std::endl << std::endl; ServerInstance->Exit(EXIT_STATUS_MODULE); } } @@ -228,7 +235,7 @@ void ModuleManager::LoadAll() for(std::map::iterator i = Modules.begin(); i != Modules.end(); i++) { Module* mod = i->second; - try + try { ServerInstance->Logs->Log("MODULE", DEBUG, "Initializing %s", i->first.c_str()); mod->init(); @@ -237,7 +244,7 @@ void ModuleManager::LoadAll() { LastModuleError = "Unable to initialize " + mod->ModuleSourceFile + ": " + modexcept.GetReason(); ServerInstance->Logs->Log("MODULE", DEFAULT, LastModuleError); - std::cout << std::endl << "[" << con_red << "*" << con_reset << "]" << LastModuleError << std::endl << std::endl; + std::cout << std::endl << "[" << con_red << "*" << con_reset << "] " << LastModuleError << std::endl << std::endl; ServerInstance->Exit(EXIT_STATUS_MODULE); } }