From 2ab1281c4db7855515c16ec69d1294647de56f22 Mon Sep 17 00:00:00 2001 From: Sadie Powell Date: Thu, 19 Sep 2024 13:08:26 +0100 Subject: Use unique_ptr for InspIRCd::Config. --- src/configreader.cpp | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) (limited to 'src/configreader.cpp') diff --git a/src/configreader.cpp b/src/configreader.cpp index a40a5ad16..3295491bb 100644 --- a/src/configreader.cpp +++ b/src/configreader.cpp @@ -195,7 +195,7 @@ void ServerConfig::CrossCheckOperBlocks() } } -void ServerConfig::CrossCheckConnectBlocks(ServerConfig* current) +void ServerConfig::CrossCheckConnectBlocks(const std::unique_ptr& current) { typedef std::map, std::shared_ptr> ClassMap; ClassMap oldBlocksByMask; @@ -422,7 +422,7 @@ void ServerConfig::Read() } } -void ServerConfig::Apply(ServerConfig* old, const std::string& useruid) +void ServerConfig::Apply(const std::unique_ptr& old, const std::string& useruid) { valid = true; if (old) @@ -687,12 +687,12 @@ void ConfigReaderThread::OnStart() void ConfigReaderThread::OnStop() { - ServerConfig* old = ServerInstance->Config; ServerInstance->Logs.Normal("CONFIG", "Switching to new configuration..."); - ServerInstance->Config = this->Config; - Config->Apply(old, UUID); - if (Config->valid) + std::swap(ServerInstance->Config, this->Config); + ServerInstance->Config->Apply(this->Config, UUID); + + if (ServerInstance->Config->valid) { /* * Apply the changed configuration from the rehash. @@ -736,17 +736,15 @@ void ConfigReaderThread::OnStop() user->WriteNotice("Cannot open log files: " + ex.GetReason()); } - if (Config->RawLog && !old->RawLog) + if (!Config->RawLog && ServerInstance->Config->RawLog) { for (auto* luser : ServerInstance->Users.GetLocalUsers()) Log::NotifyRawIO(luser, MessageType::PRIVMSG); } - - Config = old; } else { // whoops, abort! - ServerInstance->Config = old; + std::swap(ServerInstance->Config, this->Config); } } -- cgit v1.3.1-10-gc9f91