diff options
-rw-r--r-- | src/modules/m_spanningtree/treeserver.cpp | 19 | ||||
-rw-r--r-- | src/modules/m_spanningtree/treesocket1.cpp | 3 |
2 files changed, 15 insertions, 7 deletions
diff --git a/src/modules/m_spanningtree/treeserver.cpp b/src/modules/m_spanningtree/treeserver.cpp index 5a2d4f886..ef0fe4472 100644 --- a/src/modules/m_spanningtree/treeserver.cpp +++ b/src/modules/m_spanningtree/treeserver.cpp @@ -191,14 +191,12 @@ void TreeServer::SQuitChild(TreeServer* server, const std::string& reason) ServerInstance->SNO->WriteToSnoMask(IsRoot() ? '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" : ""); - server->Tidy(); - // No-op if the socket is already closed (i.e. it called us) if (server->IsLocal()) server->GetSocket()->Close(); - server->cull(); - delete server; + // Add the server to the cull list, the servers behind it are handled by cull() and the destructor + ServerInstance->GlobalCulls.AddItem(server); } void TreeServer::SQuitInternal(const std::string& reason, int& num_lost_servers, int& num_lost_users) @@ -353,6 +351,13 @@ void TreeServer::Tidy() CullResult TreeServer::cull() { + // Recursively cull all servers that are under us in the tree + for (ChildServers::const_iterator i = Children.begin(); i != Children.end(); ++i) + { + TreeServer* server = *i; + server->cull(); + } + if (!IsRoot()) ServerUser->cull(); return classbase::cull(); @@ -360,7 +365,11 @@ CullResult TreeServer::cull() TreeServer::~TreeServer() { - /* We'd better tidy up after ourselves, eh? */ + // Recursively delete all servers that are under us in the tree first + for (ChildServers::const_iterator i = Children.begin(); i != Children.end(); ++i) + delete *i; + + // Delete server user unless it's us if (!IsRoot()) delete ServerUser; } diff --git a/src/modules/m_spanningtree/treesocket1.cpp b/src/modules/m_spanningtree/treesocket1.cpp index 27d7b1a57..8dd62a1e9 100644 --- a/src/modules/m_spanningtree/treesocket1.cpp +++ b/src/modules/m_spanningtree/treesocket1.cpp @@ -157,8 +157,7 @@ CmdResult CommandSQuit::HandleServer(TreeServer* server, std::vector<std::string server->SQuitChild(quitting, params[1]); // 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. + // to stop this message from being forwarded. // The squit logic generates a SQUIT message with our sid as the source and sends it to the // remaining servers. return ret; |