]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules.cpp
Ensure all dynrefs with the same target resolve to the same object when one name...
[user/henk/code/inspircd.git] / src / modules.cpp
index 4c0af3bace5e40baac7f348afb9a164f07d3a5a2..6510c9423f19bb51f500096308471aa8649d5077 100644 (file)
@@ -121,7 +121,6 @@ ModResult   Module::OnChangeLocalUserGECOS(LocalUser*, const std::string&) { Detac
 ModResult      Module::OnPreTopicChange(User*, Channel*, const std::string&) { DetachEvent(I_OnPreTopicChange); return MOD_RES_PASSTHRU; }
 void           Module::OnEvent(Event&) { DetachEvent(I_OnEvent); }
 ModResult      Module::OnPassCompare(Extensible* ex, const std::string &password, const std::string &input, const std::string& hashtype) { DetachEvent(I_OnPassCompare); return MOD_RES_PASSTHRU; }
-void           Module::OnGlobalOper(User*) { DetachEvent(I_OnGlobalOper); }
 void           Module::OnPostConnect(User*) { DetachEvent(I_OnPostConnect); }
 void           Module::OnUserMessage(User*, void*, int, const std::string&, char, const CUList&, MessageType) { DetachEvent(I_OnUserMessage); }
 void           Module::OnUserInvite(User*, User*, Channel*, time_t) { DetachEvent(I_OnUserInvite); }
@@ -178,7 +177,7 @@ ModuleManager::~ModuleManager()
 
 bool ModuleManager::Attach(Implementation i, Module* mod)
 {
-       if (std::find(EventHandlers[i].begin(), EventHandlers[i].end(), mod) != EventHandlers[i].end())
+       if (stdalgo::isin(EventHandlers[i], mod))
                return false;
 
        EventHandlers[i].push_back(mod);
@@ -685,8 +684,10 @@ void dynamic_reference_base::SetProvider(const std::string& newname)
 
 void dynamic_reference_base::resolve()
 {
-       std::multimap<std::string, ServiceProvider*>::iterator i = ServerInstance->Modules->DataProviders.find(name);
-       if (i != ServerInstance->Modules->DataProviders.end())
+       // Because find() may return any element with a matching key in case count(key) > 1 use lower_bound()
+       // to ensure a dynref with the same name as another one resolves to the same object
+       std::multimap<std::string, ServiceProvider*>::iterator i = ServerInstance->Modules.DataProviders.lower_bound(name);
+       if ((i != ServerInstance->Modules.DataProviders.end()) && (i->first == this->name))
                value = static_cast<DataProvider*>(i->second);
        else
                value = NULL;