From 467b276d9d0407ec412262525c43c28d47fdae2f Mon Sep 17 00:00:00 2001 From: Attila Molnar Date: Fri, 13 Jun 2014 15:27:40 +0200 Subject: [PATCH] Change allocation of InspIRCd::BanCache to be physically part of the object containing it --- include/inspircd.h | 2 +- src/inspircd.cpp | 3 --- src/usermanager.cpp | 3 ++- src/users.cpp | 2 +- src/xline.cpp | 6 +++--- 5 files changed, 7 insertions(+), 9 deletions(-) diff --git a/include/inspircd.h b/include/inspircd.h index 60c8f761d..e575cd8b0 100644 --- a/include/inspircd.h +++ b/include/inspircd.h @@ -365,7 +365,7 @@ class CoreExport InspIRCd /** BanCacheManager is used to speed up checking of restrictions on connection * to the IRCd. */ - BanCacheManager *BanCache; + BanCacheManager BanCache; /** Stats class, holds miscellaneous stats counters */ diff --git a/src/inspircd.cpp b/src/inspircd.cpp index c878138fe..898b4f455 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -133,7 +133,6 @@ void InspIRCd::Cleanup() DeleteZero(this->XLines); DeleteZero(this->Parser); DeleteZero(this->Modules); - DeleteZero(this->BanCache); DeleteZero(this->SNO); DeleteZero(this->Config); DeleteZero(this->PI); @@ -262,7 +261,6 @@ InspIRCd::InspIRCd(int argc, char** argv) : this->Users = 0; this->Config = 0; this->SNO = 0; - this->BanCache = 0; this->Modules = 0; this->Parser = 0; this->XLines = 0; @@ -286,7 +284,6 @@ InspIRCd::InspIRCd(int argc, char** argv) : this->Config = new ServerConfig; this->SNO = new SnomaskManager; - this->BanCache = new BanCacheManager; this->Modules = new ModuleManager(); dynamic_reference_base::reset_all(); this->Parser = new CommandParser; diff --git a/src/usermanager.cpp b/src/usermanager.cpp index 665149e48..37f64b9d2 100644 --- a/src/usermanager.cpp +++ b/src/usermanager.cpp @@ -104,7 +104,8 @@ void UserManager::AddUser(int socket, ListenSocket* via, irc::sockets::sockaddrs */ New->exempt = (ServerInstance->XLines->MatchesLine("E",New) != NULL); - if (BanCacheHit *b = ServerInstance->BanCache->GetHit(New->GetIPString())) + BanCacheHit* const b = ServerInstance->BanCache.GetHit(New->GetIPString()); + if (b) { if (!b->Type.empty() && !New->exempt) { diff --git a/src/users.cpp b/src/users.cpp index 7fba57faa..9a6c573f3 100644 --- a/src/users.cpp +++ b/src/users.cpp @@ -599,7 +599,7 @@ void LocalUser::FullConnect() ServerInstance->SNO->WriteToSnoMask('c',"Client connecting on port %d (class %s): %s (%s) [%s]", this->GetServerPort(), this->MyClass->name.c_str(), GetFullRealHost().c_str(), this->GetIPString().c_str(), this->fullname.c_str()); ServerInstance->Logs->Log("BANCACHE", LOG_DEBUG, "BanCache: Adding NEGATIVE hit for " + this->GetIPString()); - ServerInstance->BanCache->AddHit(this->GetIPString(), "", ""); + ServerInstance->BanCache.AddHit(this->GetIPString(), "", ""); // reset the flood penalty (which could have been raised due to things like auto +x) CommandFloodPenalty = 0; } diff --git a/src/xline.cpp b/src/xline.cpp index 9b90c56f7..c48db51b1 100644 --- a/src/xline.cpp +++ b/src/xline.cpp @@ -275,7 +275,7 @@ bool XLineManager::AddLine(XLine* line, User* user) if (!xlf) return false; - ServerInstance->BanCache->RemoveEntries(line->type, false); // XXX perhaps remove ELines here? + ServerInstance->BanCache.RemoveEntries(line->type, false); // XXX perhaps remove ELines here? if (xlf->AutoApplyToUserList(line)) pending_lines.push_back(line); @@ -305,7 +305,7 @@ bool XLineManager::DelLine(const char* hostmask, const std::string &type, User* if (simulate) return true; - ServerInstance->BanCache->RemoveEntries(y->second->type, true); + ServerInstance->BanCache.RemoveEntries(y->second->type, true); FOREACH_MOD(OnDelLine, (user, y->second)); @@ -544,7 +544,7 @@ void XLine::DefaultApply(User* u, const std::string &line, bool bancache) if (bancache) { ServerInstance->Logs->Log("BANCACHE", LOG_DEBUG, "BanCache: Adding positive hit (" + line + ") for " + u->GetIPString()); - ServerInstance->BanCache->AddHit(u->GetIPString(), this->type, banReason, this->duration); + ServerInstance->BanCache.AddHit(u->GetIPString(), this->type, banReason, this->duration); } } -- 2.39.2