- std::vector<ExtensionItem*> items = Extensible::BeginUnregister(modfind->second);
- /* Give the module a chance to tidy out all its metadata */
- for (chan_hash::iterator c = ServerInstance->chanlist->begin(); c != ServerInstance->chanlist->end(); c++)
- {
- modfind->second->OnCleanup(TYPE_CHANNEL,c->second);
- c->second->doUnhookExtensions(items);
- const UserMembList* users = c->second->GetUsers();
- for(UserMembCIter mi = users->begin(); mi != users->end(); mi++)
- mi->second->doUnhookExtensions(items);
- }
- for (user_hash::iterator u = ServerInstance->Users->clientlist->begin(); u != ServerInstance->Users->clientlist->end(); u++)
- {
- modfind->second->OnCleanup(TYPE_USER,u->second);
- u->second->doUnhookExtensions(items);
- }
-
- /* Tidy up any dangling resolvers */
- ServerInstance->Res->CleanResolvers(modfind->second);
-
- FOREACH_MOD(I_OnUnloadModule,OnUnloadModule(modfind->second, modfind->first));
-
- this->DetachAll(modfind->second);
-
- ServerInstance->Parser->RemoveCommands(modfind->second);
- ServerInstance->Modes->RemoveModes(modfind->second);
-
- ServerInstance->GlobalCulls.AddItem(modfind->second);
- Modules.erase(modfind);
-
- ServerInstance->Logs->Log("MODULE", DEFAULT,"Module %s unloaded",filename);
- this->ModCount--;
- ServerInstance->BuildISupport();
- return true;
- }
-
- LastModuleError = "Module " + filename_str + " is not loaded, cannot unload it!";
- ServerInstance->Logs->Log("MODULE", DEFAULT, LastModuleError);
- return false;