summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAttila Molnar <attilamolnar@hush.com>2014-07-28 14:34:46 +0200
committerAttila Molnar <attilamolnar@hush.com>2014-07-28 14:34:46 +0200
commit8a7ed312cfcd47a39ac07b146b4aaf5f9ca1c0e2 (patch)
tree5afa5e8eb6767334f789133a899bb3ded0534594 /src
parent001e9c1372a1c6fc2877f9d6607cf662f09228df (diff)
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
Diffstat (limited to 'src')
-rw-r--r--src/modules/m_spanningtree/treeserver.cpp19
-rw-r--r--src/modules/m_spanningtree/treesocket1.cpp3
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;