From 48253b1103dcdcd8252808bd021519772b223143 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Mon, 13 Oct 2014 21:16:51 +0200 Subject: m_spanningtree Rebuild serverlist and sidlist when receiving a specific Request Issue #923 --- src/modules/m_spanningtree/main.cpp | 6 ++++++ src/modules/m_spanningtree/main.h | 1 + src/modules/m_spanningtree/utils.cpp | 13 +++++++++++++ src/modules/m_spanningtree/utils.h | 5 +++++ 4 files changed, 25 insertions(+) (limited to 'src') diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index e7ff3789b..5f06cad58 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -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 &translate) { TreeSocket* s = (TreeSocket*)opaque; diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h index eb17c4195..17adc9287 100644 --- a/src/modules/m_spanningtree/main.h +++ b/src/modules/m_spanningtree/main.h @@ -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(); diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp index 3bd0aa2c7..367a3b921 100644 --- a/src/modules/m_spanningtree/utils.cpp +++ b/src/modules/m_spanningtree/utils.cpp @@ -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); +} diff --git a/src/modules/m_spanningtree/utils.h b/src/modules/m_spanningtree/utils.h index a0543b6bd..5559b3459 100644 --- a/src/modules/m_spanningtree/utils.h +++ b/src/modules/m_spanningtree/utils.h @@ -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 -- cgit v1.2.3