From 4fbd6681fedbff9b4cb04cc774f785cbe8b5c35b Mon Sep 17 00:00:00 2001 From: linuxdaemon Date: Tue, 18 Dec 2018 19:06:56 -0600 Subject: 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 --- src/modules/m_censor.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'src/modules/m_censor.cpp') 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(" 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 -- cgit v1.3.1-10-gc9f91