From 77e8e0bccac5cdd4f3cfcba9ea07e7b4fd80dec2 Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Fri, 5 Apr 2013 00:47:26 +0200 Subject: Run OnUnloadModule hook before starting to unregister services provided by the module --- src/modules.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/modules.cpp b/src/modules.cpp index 1194e8358..1d91bb006 100644 --- a/src/modules.cpp +++ b/src/modules.cpp @@ -345,6 +345,11 @@ bool ModuleManager::CanUnload(Module* mod) void ModuleManager::DoSafeUnload(Module* mod) { + // First, notify all modules that a module is about to be unloaded, so in case + // they pass execution to the soon to be unloaded module, it will happen now, + // i.e. before we unregister the services of the module being unloaded + FOREACH_MOD(I_OnUnloadModule,OnUnloadModule(mod)); + std::map::iterator modfind = Modules.find(mod->ModuleSourceFile); std::vector > items; @@ -385,8 +390,6 @@ void ModuleManager::DoSafeUnload(Module* mod) /* Tidy up any dangling resolvers */ ServerInstance->Res->CleanResolvers(mod); - FOREACH_MOD(I_OnUnloadModule,OnUnloadModule(mod)); - DetachAll(mod); Modules.erase(modfind); -- cgit v1.2.3