diff options
author | Attila Molnar <attilamolnar@hush.com> | 2014-10-13 21:16:51 +0200 |
---|---|---|
committer | Attila Molnar <attilamolnar@hush.com> | 2014-10-13 21:16:51 +0200 |
commit | 48253b1103dcdcd8252808bd021519772b223143 (patch) | |
tree | 709f588d9a3d5af774a071fd412993ac5f48018a /src/modules | |
parent | 156c35c91f5c69a77a76f6b60db1ea61581bc13f (diff) |
m_spanningtree Rebuild serverlist and sidlist when receiving a specific Request
Issue #923
Diffstat (limited to 'src/modules')
-rw-r--r-- | src/modules/m_spanningtree/main.cpp | 6 | ||||
-rw-r--r-- | src/modules/m_spanningtree/main.h | 1 | ||||
-rw-r--r-- | src/modules/m_spanningtree/utils.cpp | 13 | ||||
-rw-r--r-- | src/modules/m_spanningtree/utils.h | 5 |
4 files changed, 25 insertions, 0 deletions
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<TranslateType> &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 |