From d618b3c186e58a55ab5103da2790459daed6c45e Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Mon, 28 Jul 2014 14:38:20 +0200 Subject: m_spanningtree Mark servers awaiting destruction after being lost in a netsplit, add TreeServer::IsDead() --- src/modules/m_spanningtree/treeserver.cpp | 8 ++++++-- src/modules/m_spanningtree/treeserver.h | 9 +++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/modules/m_spanningtree/treeserver.cpp b/src/modules/m_spanningtree/treeserver.cpp index d758785d4..a47522203 100644 --- a/src/modules/m_spanningtree/treeserver.cpp +++ b/src/modules/m_spanningtree/treeserver.cpp @@ -37,7 +37,8 @@ TreeServer::TreeServer() , Parent(NULL), Route(NULL) , VersionString(ServerInstance->GetVersionString()) , fullversion(ServerInstance->GetVersionString(true)) - , Socket(NULL), sid(ServerInstance->Config->GetSID()), behind_bursting(0), ServerUser(ServerInstance->FakeClient) + , Socket(NULL), sid(ServerInstance->Config->GetSID()), behind_bursting(0), isdead(false) + , ServerUser(ServerInstance->FakeClient) , age(ServerInstance->Time()), Warned(false), UserCount(ServerInstance->Users.GetLocalUsers().size()) , OperCount(0), rtt(0), StartBurst(0), Hidden(false) { @@ -50,7 +51,8 @@ TreeServer::TreeServer() */ TreeServer::TreeServer(const std::string& Name, const std::string& Desc, const std::string& id, TreeServer* Above, TreeSocket* Sock, bool Hide) : Server(Name, Desc) - , Parent(Above), Socket(Sock), sid(id), behind_bursting(Parent->behind_bursting), ServerUser(new FakeUser(id, this)) + , Parent(Above), Socket(Sock), sid(id), behind_bursting(Parent->behind_bursting), isdead(false) + , ServerUser(new FakeUser(id, this)) , age(ServerInstance->Time()), Warned(false), UserCount(0), OperCount(0), rtt(0), StartBurst(0), Hidden(Hide) { ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "New server %s behind_bursting %u", GetName().c_str(), behind_bursting); @@ -209,6 +211,8 @@ void TreeServer::SQuitInternal(const std::string& reason, int& num_lost_servers, server->SQuitInternal(reason, num_lost_servers, num_lost_users); } + // Mark server as dead + isdead = true; num_lost_servers++; num_lost_users += QuitUsers(reason); RemoveHash(); diff --git a/src/modules/m_spanningtree/treeserver.h b/src/modules/m_spanningtree/treeserver.h index 69305a240..86666211f 100644 --- a/src/modules/m_spanningtree/treeserver.h +++ b/src/modules/m_spanningtree/treeserver.h @@ -60,6 +60,10 @@ class TreeServer : public Server */ unsigned int behind_bursting; + /** True if this server has been lost in a split and is awaiting destruction + */ + bool isdead; + /** This method is used to add this TreeServer to the * hash maps. It is only called by the constructors. */ @@ -125,6 +129,11 @@ class TreeServer : public Server */ bool IsLocal() const { return (this->Route == this); } + /** Returns true if the server is awaiting destruction + * @return True if the server is waiting to be culled and deleted, false otherwise + */ + bool IsDead() const { return isdead; } + /** Get server version string */ const std::string& GetVersion(); -- cgit v1.2.3