X-Git-Url: https://git.netwichtig.de/gitweb/?a=blobdiff_plain;f=src%2Fmodules%2Fm_spanningtree%2Ftreeserver.cpp;h=e004f897ec55bc831d47a992b8a4fdea4cd28871;hb=bdc70892c647f0d7672aba413100730819a4b217;hp=9b92ba988099f5e87ee3bdc87f9c95a882ee7420;hpb=7bef57c770fd5cdfa0ad10caf30273f6e42a90d7;p=user%2Fhenk%2Fcode%2Finspircd.git diff --git a/src/modules/m_spanningtree/treeserver.cpp b/src/modules/m_spanningtree/treeserver.cpp index 9b92ba988..e004f897e 100644 --- a/src/modules/m_spanningtree/treeserver.cpp +++ b/src/modules/m_spanningtree/treeserver.cpp @@ -38,8 +38,9 @@ TreeServer::TreeServer() , VersionString(ServerInstance->GetVersionString()) , fullversion(ServerInstance->GetVersionString(true)) , Socket(NULL), sid(ServerInstance->Config->GetSID()), behind_bursting(0), isdead(false) + , pingtimer(this) , ServerUser(ServerInstance->FakeClient) - , age(ServerInstance->Time()), Warned(false), UserCount(ServerInstance->Users.GetLocalUsers().size()) + , age(ServerInstance->Time()), UserCount(ServerInstance->Users.GetLocalUsers().size()) , OperCount(0), rtt(0), StartBurst(0), Hidden(false) { AddHashEntry(); @@ -52,13 +53,14 @@ 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), isdead(false) + , pingtimer(this) , ServerUser(new FakeUser(id, this)) - , age(ServerInstance->Time()), Warned(false), UserCount(0), OperCount(0), rtt(0), StartBurst(0), Hidden(Hide) + , age(ServerInstance->Time()), 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); CheckULine(); - SetNextPingTime(ServerInstance->Time() + Utils->PingFreq); - SetPingFlag(); + + ServerInstance->Timers.AddTimer(&pingtimer); /* find the 'route' for this server (e.g. the one directly connected * to the local server, which we can use to reach it) @@ -112,7 +114,7 @@ TreeServer::TreeServer(const std::string& Name, const std::string& Desc, const s */ this->AddHashEntry(); - Parent->AddChild(this); + Parent->Children.push_back(this); } void TreeServer::BeginBurst(unsigned long startms) @@ -127,11 +129,6 @@ void TreeServer::BeginBurst(unsigned long startms) ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "Server %s started bursting at time %lu behind_bursting %u", sid.c_str(), startms, behind_bursting); } -const std::string& TreeServer::GetID() -{ - return sid; -} - void TreeServer::FinishBurstInternal() { // Check is needed because 1202 protocol servers don't send the bursting state of a server, so servers @@ -140,11 +137,6 @@ void TreeServer::FinishBurstInternal() behind_bursting--; ServerInstance->Logs->Log(MODNAME, LOG_DEBUG, "FinishBurstInternal() %s behind_bursting %u", GetName().c_str(), behind_bursting); - if (!IsBehindBursting()) - { - SetNextPingTime(ServerInstance->Time() + Utils->PingFreq); - SetPingFlag(); - } for (ChildServers::const_iterator i = Children.begin(); i != Children.end(); ++i) { TreeServer* child = *i; @@ -168,7 +160,7 @@ void TreeServer::FinishBurst() void TreeServer::SQuitChild(TreeServer* server, const std::string& reason) { DelServerEvent(Utils->Creator, server->GetName()); - DelChild(server); + stdalgo::erase(Children, server); if (IsRoot()) { @@ -266,71 +258,6 @@ void TreeServer::AddHashEntry() Utils->sidlist[sid] = this; } -/** These accessors etc should be pretty self- - * explanitory. - */ -TreeServer* TreeServer::GetRoute() -{ - return Route; -} - -const std::string& TreeServer::GetVersion() -{ - return VersionString; -} - -void TreeServer::SetNextPingTime(time_t t) -{ - this->NextPing = t; - LastPingWasGood = false; -} - -time_t TreeServer::NextPingTime() -{ - return NextPing; -} - -bool TreeServer::AnsweredLastPing() -{ - return LastPingWasGood; -} - -void TreeServer::SetPingFlag() -{ - LastPingWasGood = true; -} - -TreeSocket* TreeServer::GetSocket() -{ - return Socket; -} - -TreeServer* TreeServer::GetParent() -{ - return Parent; -} - -void TreeServer::SetVersion(const std::string &Version) -{ - VersionString = Version; -} - -void TreeServer::AddChild(TreeServer* Child) -{ - Children.push_back(Child); -} - -bool TreeServer::DelChild(TreeServer* Child) -{ - std::vector::iterator it = std::find(Children.begin(), Children.end(), Child); - if (it != Children.end()) - { - Children.erase(it); - return true; - } - return false; -} - CullResult TreeServer::cull() { // Recursively cull all servers that are under us in the tree @@ -358,6 +285,10 @@ TreeServer::~TreeServer() void TreeServer::RemoveHash() { + // XXX: Erase server from UserManager::uuidlist now, to allow sid reuse in the current main loop + // iteration, before the cull list is applied + ServerInstance->Users->uuidlist.erase(sid); + Utils->sidlist.erase(sid); Utils->serverlist.erase(GetName()); }