- Module* newmod = NULL;
- ircd_module* newhandle = NULL;
-
- try
- {
- /* This will throw a CoreException if there's a problem loading
- * the module file or getting a pointer to the init_module symbol.
- */
- newhandle = new ircd_module(ServerInstance, modfile, "init_module");
- newmod = newhandle->CallInit();
-
- if (newmod)
- {
- newmod->ModuleSourceFile = filename_str;
- Version v = newmod->GetVersion();
-
- if (v.API != API_VERSION)
- {
- DetachAll(newmod);
- delete newmod;
- delete newhandle;
- LastModuleError = "Unable to load " + filename_str + ": Incorrect module API version: " + ConvToStr(v.API) + " (our version: " + ConvToStr(API_VERSION) + ")";
- ServerInstance->Logs->Log("MODULE", DEFAULT, LastModuleError);
- return false;
- }
- else
- {
- ServerInstance->Logs->Log("MODULE", DEFAULT,"New module introduced: %s (API version %d, Module version %s)%s", filename, v.API, v.version.c_str(), (!(v.Flags & VF_VENDOR) ? " [3rd Party]" : " [Vendor]"));
- }
+void ModuleManager::DoSafeUnload(Module* mod)
+{
+ std::map<std::string, Module*>::iterator modfind = Modules.find(mod->ModuleSourceFile);