]> git.netwichtig.de Git - user/henk/code/inspircd.git/commitdiff
m_spanningtree Rebuild serverlist and sidlist when receiving a specific Request
authorAttila Molnar <attilamolnar@hush.com>
Mon, 13 Oct 2014 19:16:51 +0000 (21:16 +0200)
committerAttila Molnar <attilamolnar@hush.com>
Mon, 13 Oct 2014 19:16:51 +0000 (21:16 +0200)
Issue #923

src/modules/m_spanningtree/main.cpp
src/modules/m_spanningtree/main.h
src/modules/m_spanningtree/utils.cpp
src/modules/m_spanningtree/utils.h

index e7ff3789bfe7b6ca8253b8c6b25f0397a1fcd0be..5f06cad586a4eee63e2e4061c4ee7c4cb9af047f 100644 (file)
@@ -930,6 +930,12 @@ ModResult ModuleSpanningTree::OnSetAway(User* user, const std::string &awaymsg)
        return MOD_RES_PASSTHRU;
 }
 
+void ModuleSpanningTree::OnRequest(Request& request)
+{
+       if (!strcmp(request.id, "rehash"))
+               Utils->Rehash();
+}
+
 void ModuleSpanningTree::ProtoSendMode(void* opaque, TargetTypeFlags target_type, void* target, const parameterlist &modeline, const std::vector<TranslateType> &translate)
 {
        TreeSocket* s = (TreeSocket*)opaque;
index eb17c4195fe8bc6b42823202d9ed891da5792ca5..17adc928780a4f9f3aa04f01bd4686c5a2acfcbc 100644 (file)
@@ -178,6 +178,7 @@ class ModuleSpanningTree : public Module
        void OnLoadModule(Module* mod);
        void OnUnloadModule(Module* mod);
        ModResult OnAcceptConnection(int newsock, ListenSocket* from, irc::sockets::sockaddrs* client, irc::sockets::sockaddrs* server);
+       void OnRequest(Request& request);
        CullResult cull();
        ~ModuleSpanningTree();
        Version GetVersion();
index 3bd0aa2c7a7967e4b152ac7d411fb54cf2896979..367a3b921a88da46f5d7477c2c8ea17a004a60ac 100644 (file)
@@ -428,3 +428,16 @@ Link* SpanningTreeUtilities::FindLink(const std::string& name)
        }
        return NULL;
 }
+
+void SpanningTreeUtilities::Rehash()
+{
+       server_hash temp;
+       for (server_hash::const_iterator i = serverlist.begin(); i != serverlist.end(); ++i)
+               temp.insert(std::make_pair(i->first, i->second));
+       serverlist.swap(temp);
+       temp.clear();
+
+       for (server_hash::const_iterator i = sidlist.begin(); i != sidlist.end(); ++i)
+               temp.insert(std::make_pair(i->first, i->second));
+       sidlist.swap(temp);
+}
index a0543b6bd30ae0d3e12b8d23b9d7b9cd2eccfa8a..5559b3459b5defe2b1942a618f6077acacd7b7c9 100644 (file)
@@ -173,6 +173,11 @@ class SpanningTreeUtilities : public classbase
        /** Refresh the IP cache used for allowing inbound connections
         */
        void RefreshIPCache();
+
+       /** Recreate serverlist and sidlist, this is needed because of m_nationalchars changing
+        * national_case_insensitive_map which is used by the hash function
+        */
+       void Rehash();
 };
 
 #endif