diff options
author | attilamolnar <attilamolnar@hush.com> | 2013-07-19 13:24:36 +0200 |
---|---|---|
committer | attilamolnar <attilamolnar@hush.com> | 2013-08-22 13:42:20 +0200 |
commit | 15f4e6b865de11299e7688f28415957737999e02 (patch) | |
tree | 76fba0730b8c8e9aea35384c3b99c0d723935d94 | |
parent | 5cc9614e73a783dec7a8e0887a0435cf577eaad4 (diff) |
m_spanningtree Implement DoOneToMany() using DoOneToAllButSender()
-rw-r--r-- | src/modules/m_spanningtree/main.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/postcommand.cpp | 10 | ||||
-rw-r--r-- | src/modules/m_spanningtree/server.cpp | 2 | ||||
-rw-r--r-- | src/modules/m_spanningtree/treesocket2.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_spanningtree/utils.cpp | 15 | ||||
-rw-r--r-- | src/modules/m_spanningtree/utils.h | 7 |
6 files changed, 13 insertions, 27 deletions
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index 6e4277c08..316ed6e96 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -641,7 +641,7 @@ void ModuleSpanningTree::OnPreRehash(User* user, const std::string ¶meter) { parameterlist params; params.push_back(parameter); - Utils->DoOneToAllButSender(user ? user->uuid : ServerInstance->Config->GetSID(), "REHASH", params, user ? user->server : ServerInstance->Config->ServerName); + Utils->DoOneToAllButSender(user ? user->uuid : ServerInstance->Config->GetSID(), "REHASH", params, user ? Utils->BestRouteTo(user->server) : NULL); } } diff --git a/src/modules/m_spanningtree/postcommand.cpp b/src/modules/m_spanningtree/postcommand.cpp index 3fb3d5b07..ac416031d 100644 --- a/src/modules/m_spanningtree/postcommand.cpp +++ b/src/modules/m_spanningtree/postcommand.cpp @@ -108,10 +108,7 @@ void SpanningTreeUtilities::RouteCommand(TreeServer* origin, CommandBase* thiscm } else if (dest[0] == '$') { - if (origin) - DoOneToAllButSender(user->uuid, sent_cmd, params, origin->GetName()); - else - DoOneToMany(user->uuid, sent_cmd, params); + DoOneToAllButSender(user->uuid, sent_cmd, params, origin); } else { @@ -128,10 +125,7 @@ void SpanningTreeUtilities::RouteCommand(TreeServer* origin, CommandBase* thiscm } else if (routing.type == ROUTE_TYPE_BROADCAST || routing.type == ROUTE_TYPE_OPT_BCAST) { - if (origin) - DoOneToAllButSender(user->uuid, sent_cmd, params, origin->GetName()); - else - DoOneToMany(user->uuid, sent_cmd, params); + DoOneToAllButSender(user->uuid, sent_cmd, params, origin); } else if (routing.type == ROUTE_TYPE_UNICAST || routing.type == ROUTE_TYPE_OPT_UCAST) { diff --git a/src/modules/m_spanningtree/server.cpp b/src/modules/m_spanningtree/server.cpp index 538d28dbd..36bd8620a 100644 --- a/src/modules/m_spanningtree/server.cpp +++ b/src/modules/m_spanningtree/server.cpp @@ -150,7 +150,7 @@ bool TreeSocket::Outbound_Reply_Server(parameterlist ¶ms) /* IMPORTANT: Take password/hmac hash OUT of here before we broadcast the introduction! */ params[1] = "*"; - Utils->DoOneToAllButSender(ServerInstance->Config->GetSID(),"SERVER",params,sname); + Utils->DoOneToAllButSender(ServerInstance->Config->GetSID(),"SERVER",params,MyRoot); return true; } diff --git a/src/modules/m_spanningtree/treesocket2.cpp b/src/modules/m_spanningtree/treesocket2.cpp index 986e71cfe..5181dfeea 100644 --- a/src/modules/m_spanningtree/treesocket2.cpp +++ b/src/modules/m_spanningtree/treesocket2.cpp @@ -184,8 +184,8 @@ void TreeSocket::ProcessLine(std::string &line) sparams.push_back("0"); sparams.push_back(MyRoot->GetID()); sparams.push_back(":" + MyRoot->GetDesc()); - Utils->DoOneToAllButSender(ServerInstance->Config->GetSID(), "SERVER", sparams, MyRoot->GetName()); - Utils->DoOneToAllButSender(MyRoot->GetID(), "BURST", params, MyRoot->GetName()); + Utils->DoOneToAllButSender(ServerInstance->Config->GetSID(), "SERVER", sparams, MyRoot); + Utils->DoOneToAllButSender(MyRoot->GetID(), "BURST", params, MyRoot); } else if (command == "ERROR") { diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp index ef1070a12..e7edc65d6 100644 --- a/src/modules/m_spanningtree/utils.cpp +++ b/src/modules/m_spanningtree/utils.cpp @@ -205,9 +205,8 @@ std::string SpanningTreeUtilities::ConstructLine(const std::string& prefix, cons return FullLine; } -void SpanningTreeUtilities::DoOneToAllButSender(const std::string& prefix, const std::string& command, const parameterlist& params, const std::string& omit) +void SpanningTreeUtilities::DoOneToAllButSender(const std::string& prefix, const std::string& command, const parameterlist& params, TreeServer* omitroute) { - TreeServer* omitroute = this->BestRouteTo(omit); std::string FullLine = ConstructLine(prefix, command, params); unsigned int items = this->TreeRoot->ChildCount(); @@ -222,18 +221,6 @@ void SpanningTreeUtilities::DoOneToAllButSender(const std::string& prefix, const } } -void SpanningTreeUtilities::DoOneToMany(const std::string &prefix, const std::string &command, const parameterlist ¶ms) -{ - std::string FullLine = ConstructLine(prefix, command, params); - - unsigned int items = this->TreeRoot->ChildCount(); - for (unsigned int x = 0; x < items; x++) - { - TreeServer* Route = this->TreeRoot->GetChild(x); - Route->GetSocket()->WriteLine(FullLine); - } -} - bool SpanningTreeUtilities::DoOneToOne(const std::string& prefix, const std::string& command, const parameterlist& params, const std::string& target) { TreeServer* Route = this->BestRouteTo(target); diff --git a/src/modules/m_spanningtree/utils.h b/src/modules/m_spanningtree/utils.h index 58821bd2b..491c4126f 100644 --- a/src/modules/m_spanningtree/utils.h +++ b/src/modules/m_spanningtree/utils.h @@ -134,7 +134,7 @@ class SpanningTreeUtilities : public classbase /** Send a message from this server to all but one other, local or remote */ - void DoOneToAllButSender(const std::string &prefix, const std::string &command, const parameterlist& params, const std::string& omit); + void DoOneToAllButSender(const std::string& prefix, const std::string& command, const parameterlist& params, TreeServer* omit); /** Send a message from this server to all others */ @@ -180,3 +180,8 @@ class SpanningTreeUtilities : public classbase */ void SendChannelMessage(const std::string& prefix, Channel* target, const std::string &text, char status, const CUList& exempt_list, const char* message_type); }; + +inline void SpanningTreeUtilities::DoOneToMany(const std::string& prefix, const std::string& command, const parameterlist& params) +{ + DoOneToAllButSender(prefix, command, params, NULL); +} |