From 9d75ba35743eb8f44a2d7beb8e08aa43c13f5d2e Mon Sep 17 00:00:00 2001 From: attilamolnar Date: Tue, 10 Sep 2013 14:07:08 +0200 Subject: m_spanningtree Minor fixes - Handle the case when servers SQUIT themselves - Fix extra space in channel messages --- src/modules/m_spanningtree/treesocket1.cpp | 8 +++++++- src/modules/m_spanningtree/utils.cpp | 7 ++++--- 2 files changed, 11 insertions(+), 4 deletions(-) (limited to 'src/modules') diff --git a/src/modules/m_spanningtree/treesocket1.cpp b/src/modules/m_spanningtree/treesocket1.cpp index dc9bb5331..3c838177d 100644 --- a/src/modules/m_spanningtree/treesocket1.cpp +++ b/src/modules/m_spanningtree/treesocket1.cpp @@ -218,7 +218,13 @@ CmdResult CommandSQuit::HandleServer(TreeServer* server, std::vectorGetSocket(); sock->Squit(quitting, params[1]); - return CMD_SUCCESS; + + // XXX: Return CMD_FAILURE when servers SQUIT themselves (i.e. :00S SQUIT 00S :Shutting down) + // to avoid RouteCommand() being called. RouteCommand() requires a valid command source but we + // do not have one because the server user is deleted when its TreeServer is destructed. + // We generate a SQUIT in TreeSocket::Squit(), with our sid as the source and send it to the + // remaining servers. + return ((quitting == server) ? CMD_FAILURE : CMD_SUCCESS); } /** This function is called when we receive data from a remote diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp index 0ec0a57f9..0372172f5 100644 --- a/src/modules/m_spanningtree/utils.cpp +++ b/src/modules/m_spanningtree/utils.cpp @@ -365,9 +365,10 @@ Link* SpanningTreeUtilities::FindLink(const std::string& name) void SpanningTreeUtilities::SendChannelMessage(const std::string& prefix, Channel* target, const std::string& text, char status, const CUList& exempt_list, const char* message_type, TreeSocket* omit) { CmdBuilder msg(prefix, message_type); - if (status == 0) - status = ' '; - msg.push(status).push_raw(target->name).push_last(text); + msg.push_raw(' '); + if (status != 0) + msg.push_raw(status); + msg.push_raw(target->name).push_last(text); TreeSocketSet list; this->GetListOfServersForChannel(target, list, status, exempt_list); -- cgit v1.2.3