Clean up ModuleDLLManager from the Module::cull() method.

This avoids a leak which happens in some rare circumstances.
This commit is contained in:
Sadie Powell 2020-02-14 01:25:09 +00:00
parent c0f75dd4f5
commit 8d5adb667f
2 changed files with 2 additions and 5 deletions

View File

@ -720,11 +720,9 @@ class ReloadAction : public ActionBase
ReloadModule::DataKeeper datakeeper;
datakeeper.Save(mod);
DLLManager* dll = mod->ModuleDLLManager;
std::string name = mod->ModuleSourceFile;
ServerInstance->Modules->DoSafeUnload(mod);
ServerInstance->GlobalCulls.Apply();
delete dll;
bool result = ServerInstance->Modules->Load(name);
if (result)

View File

@ -64,6 +64,8 @@ Module::Module()
CullResult Module::cull()
{
if (ModuleDLLManager)
ServerInstance->GlobalCulls.AddItem(ModuleDLLManager);
return classbase::cull();
}
@ -450,11 +452,8 @@ namespace
UnloadAction(Module* m) : mod(m) {}
void Call() CXX11_OVERRIDE
{
DLLManager* dll = mod->ModuleDLLManager;
ServerInstance->Modules->DoSafeUnload(mod);
ServerInstance->GlobalCulls.Apply();
// In pure static mode this is always NULL
delete dll;
ServerInstance->GlobalCulls.AddItem(this);
}
};