summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorattilamolnar <attilamolnar@hush.com>2013-09-10 14:07:08 +0200
committerattilamolnar <attilamolnar@hush.com>2013-09-10 14:07:08 +0200
commit9d75ba35743eb8f44a2d7beb8e08aa43c13f5d2e (patch)
treed854533a0272a38a0fff0e9a35a508f7c43a7876
parent0a28c9dacb65ac46ee7dc3c6f42c81c0fc5b9de2 (diff)
m_spanningtree Minor fixes
- Handle the case when servers SQUIT themselves - Fix extra space in channel messages
-rw-r--r--src/modules/m_spanningtree/treesocket1.cpp8
-rw-r--r--src/modules/m_spanningtree/utils.cpp7
2 files changed, 11 insertions, 4 deletions
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::vector<std::string
TreeSocket* sock = server->GetSocket();
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);