]> git.netwichtig.de Git - user/henk/code/inspircd.git/blobdiff - src/modules/m_spanningtree/treesocket1.cpp
m_spanningtree Fix routing of ROUTE_TYPE_MESSAGE messages
[user/henk/code/inspircd.git] / src / modules / m_spanningtree / treesocket1.cpp
index 9376a551406142e977d9a19e5dc2847029285ee9..fa8a94f72bab89b080a8c98b91db50dba35967f1 100644 (file)
@@ -179,10 +179,10 @@ void TreeSocket::Squit(TreeServer* Current, const std::string &reason)
                        LocalSquit = true;
                        if (Current->GetSocket()->Introduced())
                        {
-                               parameterlist params;
+                               CmdBuilder params("SQUIT");
                                params.push_back(Current->GetID());
-                               params.push_back(":"+reason);
-                               Utils->DoOneToMany(Utils->TreeRoot->GetID(), "SQUIT", params);
+                               params.push_last(reason);
+                               params.Broadcast();
                        }
                }
                else
@@ -192,7 +192,12 @@ void TreeSocket::Squit(TreeServer* Current, const std::string &reason)
                int num_lost_servers = 0;
                int num_lost_users = 0;
                std::string from = Current->GetParent()->GetName()+" "+Current->GetName();
+
+               ModuleSpanningTree* st = Utils->Creator;
+               st->SplitInProgress = true;
                SquitServer(from, Current, num_lost_servers, num_lost_users);
+               st->SplitInProgress = false;
+
                ServerInstance->SNO->WriteToSnoMask(LocalSquit ? 'l' : 'L', "Netsplit complete, lost \002%d\002 user%s on \002%d\002 server%s.",
                        num_lost_users, num_lost_users != 1 ? "s" : "", num_lost_servers, num_lost_servers != 1 ? "s" : "");
                Current->Tidy();
@@ -218,7 +223,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