diff options
| author | 2024-09-19 13:08:26 +0100 | |
|---|---|---|
| committer | 2024-09-19 13:13:29 +0100 | |
| commit | 2ab1281c4db7855515c16ec69d1294647de56f22 (patch) | |
| tree | 32e93be74891874c60fa944e125d5653b83aec52 /src/configreader.cpp | |
| parent | Merge branch 'insp4' into master. (diff) | |
Use unique_ptr for InspIRCd::Config.
Diffstat (limited to 'src/configreader.cpp')
| -rw-r--r-- | src/configreader.cpp | 18 |
1 files changed, 8 insertions, 10 deletions
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<ServerConfig>& current) { typedef std::map<std::pair<std::string, ConnectClass::Type>, std::shared_ptr<ConnectClass>> 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<ServerConfig>& 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); } } |
