From 8a7ed312cfcd47a39ac07b146b4aaf5f9ca1c0e2 Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Mon, 28 Jul 2014 14:34:46 +0200 Subject: m_spanningtree Add the TreeServer that split to the cull list and destroy everything under it recursively at cull time instead of at squit processing time --- src/modules/m_spanningtree/treeserver.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'src/modules/m_spanningtree/treeserver.cpp') 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; } -- cgit v1.3.1-10-gc9f91