diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/modules/m_spanningtree/main.cpp | 5 | ||||
-rw-r--r-- | src/modules/m_spanningtree/main.h | 1 | ||||
-rw-r--r-- | src/modules/m_spanningtree/utils.cpp | 18 | ||||
-rw-r--r-- | src/modules/m_spanningtree/utils.h | 4 | ||||
-rw-r--r-- | src/usermanager.cpp | 1 | ||||
-rw-r--r-- | src/users.cpp | 66 |
6 files changed, 60 insertions, 35 deletions
diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index e3ed9fca2..db40c7f6a 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -939,6 +939,11 @@ void ModuleSpanningTree::OnEvent(Event* event) } } +void ModuleSpanningTree::cull() +{ + Utils->cull(); +} + ModuleSpanningTree::~ModuleSpanningTree() { delete ServerInstance->PI; diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h index 810b8ec92..6e3f62056 100644 --- a/src/modules/m_spanningtree/main.h +++ b/src/modules/m_spanningtree/main.h @@ -191,6 +191,7 @@ class ModuleSpanningTree : public Module void OnEvent(Event* event); void OnLoadModule(Module* mod,const std::string &name); void OnUnloadModule(Module* mod,const std::string &name); + void cull(); ~ModuleSpanningTree(); Version GetVersion(); void Prioritize(); diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp index 729f6d4ee..fc5356c66 100644 --- a/src/modules/m_spanningtree/utils.cpp +++ b/src/modules/m_spanningtree/utils.cpp @@ -157,11 +157,11 @@ SpanningTreeUtilities::SpanningTreeUtilities(ModuleSpanningTree* C) : Creator(C) this->ReadConfiguration(true); } -SpanningTreeUtilities::~SpanningTreeUtilities() +void SpanningTreeUtilities::cull() { for (unsigned int i = 0; i < Bindings.size(); i++) { - delete Bindings[i]; + Bindings[i]->cull(); } while (TreeRoot->ChildCount()) @@ -170,13 +170,21 @@ SpanningTreeUtilities::~SpanningTreeUtilities() if (child_server) { TreeSocket* sock = child_server->GetSocket(); - ServerInstance->SE->DelFd(sock); sock->Close(); } } - - // This avoids a collision on reload + ServerUser->uuid = TreeRoot->GetID(); + ServerUser->cull(); +} + +SpanningTreeUtilities::~SpanningTreeUtilities() +{ + for (unsigned int i = 0; i < Bindings.size(); i++) + { + delete Bindings[i]; + } + delete TreeRoot; delete ServerUser; } diff --git a/src/modules/m_spanningtree/utils.h b/src/modules/m_spanningtree/utils.h index 2f8fc75db..1de6de076 100644 --- a/src/modules/m_spanningtree/utils.h +++ b/src/modules/m_spanningtree/utils.h @@ -164,6 +164,10 @@ class SpanningTreeUtilities : public classbase */ SpanningTreeUtilities(ModuleSpanningTree* Creator); + /** Prepare for class destruction + */ + void cull(); + /** Destroy class and free listeners etc */ ~SpanningTreeUtilities(); diff --git a/src/usermanager.cpp b/src/usermanager.cpp index b355bc890..023e2aa5a 100644 --- a/src/usermanager.cpp +++ b/src/usermanager.cpp @@ -195,7 +195,6 @@ void UserManager::QuitUser(User *user, const std::string &quitreason, const char if (user->registered == REG_ALL) { FOREACH_MOD(I_OnUserQuit,OnUserQuit(user, reason, oper_reason)); - user->PurgeEmptyChannels(); user->WriteCommonQuit(reason, oper_reason); } diff --git a/src/users.cpp b/src/users.cpp index fb36ac324..f5eeff942 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -235,35 +235,8 @@ User::User(const std::string &uid) User::~User() { - ServerInstance->Logs->Log("USERS", DEBUG, "User destructor for %s", uuid.c_str()); - /* NULL for remote users :) */ - if (this->MyClass) - { - this->MyClass->RefCount--; - ServerInstance->Logs->Log("USERS", DEBUG, "User destructor -- connect refcount now: %lu", this->MyClass->RefCount); - if (MyClass->RefCount == 0) - delete MyClass; - } - - if (this->AllowedOperCommands) - { - delete AllowedOperCommands; - AllowedOperCommands = NULL; - } - - if (this->AllowedPrivs) - { - delete AllowedPrivs; - AllowedPrivs = NULL; - } - - this->InvalidateCache(); - this->DecrementModes(); - - if (client_sa.sa.sa_family != AF_UNSPEC) - ServerInstance->Users->RemoveCloneCounts(this); - - ServerInstance->Users->uuidlist->erase(uuid); + if (uuid.length()) + ServerInstance->Logs->Log("USERS", ERROR, "User destructor for %s called without cull", uuid.c_str()); } const std::string& User::MakeHost() @@ -599,6 +572,12 @@ void User::cull() { if (!quitting) ServerInstance->Users->QuitUser(this, "Culled without QuitUser"); + if (uuid.empty()) + { + ServerInstance->Logs->Log("USERS", DEBUG, "User culled twice? UUID empty"); + return; + } + PurgeEmptyChannels(); if (IS_LOCAL(this)) { if (fd != INT_MAX) @@ -610,6 +589,35 @@ void User::cull() else ServerInstance->Logs->Log("USERS", DEBUG, "Failed to remove user from vector"); } + + if (this->MyClass) + { + this->MyClass->RefCount--; + ServerInstance->Logs->Log("USERS", DEBUG, "User destructor -- connect refcount now: %lu", this->MyClass->RefCount); + if (MyClass->RefCount == 0) + delete MyClass; + } + + if (this->AllowedOperCommands) + { + delete AllowedOperCommands; + AllowedOperCommands = NULL; + } + + if (this->AllowedPrivs) + { + delete AllowedPrivs; + AllowedPrivs = NULL; + } + + this->InvalidateCache(); + this->DecrementModes(); + + if (client_sa.sa.sa_family != AF_UNSPEC) + ServerInstance->Users->RemoveCloneCounts(this); + + ServerInstance->Users->uuidlist->erase(uuid); + uuid.clear(); } void User::Oper(const std::string &opertype, const std::string &opername) |