diff options
author | linuxdaemon <linuxdaemon@users.noreply.github.com> | 2018-12-18 19:06:56 -0600 |
---|---|---|
committer | Peter Powell <petpow@saberuk.com> | 2018-12-19 01:06:56 +0000 |
commit | 4fbd6681fedbff9b4cb04cc774f785cbe8b5c35b (patch) | |
tree | 9df58ec3e4cf2c191b4ae0051118606957d89db6 /src/modules/m_censor.cpp | |
parent | bf0bf05ac07a4bd0afeba5a276ef86308f0f9e54 (diff) |
Make more modules rehash atomically (#1535)
Have each module validate the values it loads before setting them, so
any errors don't result in partial application of the configs
Diffstat (limited to 'src/modules/m_censor.cpp')
-rw-r--r-- | src/modules/m_censor.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/modules/m_censor.cpp b/src/modules/m_censor.cpp index a9c55386c..31309ed2f 100644 --- a/src/modules/m_censor.cpp +++ b/src/modules/m_censor.cpp @@ -104,7 +104,7 @@ class ModuleCensor : public Module * reload our config file on rehash - we must destroy and re-allocate the classes * to call the constructor again and re-read our data. */ - censors.clear(); + censor_t newcensors; ConfigTagList badwords = ServerInstance->Config->ConfTags("badword"); for (ConfigIter i = badwords.first; i != badwords.second; ++i) @@ -112,11 +112,12 @@ class ModuleCensor : public Module ConfigTag* tag = i->second; const std::string text = tag->getString("text"); if (text.empty()) - continue; + throw ModuleException("<badword:text> is empty! at " + tag->getTagLocation()); const std::string replace = tag->getString("replace"); - censors[text] = replace; + newcensors[text] = replace; } + censors.swap(newcensors); } Version GetVersion() CXX11_OVERRIDE |