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_hidelist.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_hidelist.cpp')
-rw-r--r-- | src/modules/m_hidelist.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/modules/m_hidelist.cpp b/src/modules/m_hidelist.cpp index 2d3f0be7c..9c8811fb8 100644 --- a/src/modules/m_hidelist.cpp +++ b/src/modules/m_hidelist.cpp @@ -58,19 +58,26 @@ class ModuleHideList : public Module public: void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { - stdalgo::delete_all(watchers); - watchers.clear(); - ConfigTagList tags = ServerInstance->Config->ConfTags("hidelist"); + typedef std::vector<std::pair<std::string, unsigned int> > NewConfigs; + NewConfigs newconfigs; for (ConfigIter i = tags.first; i != tags.second; ++i) { ConfigTag* tag = i->second; std::string modename = tag->getString("mode"); + if (modename.empty()) + throw ModuleException("Empty <hidelist:mode> at " + tag->getTagLocation()); // If rank is set to 0 everyone inside the channel can view the list, // but non-members may not unsigned int rank = tag->getUInt("rank", HALFOP_VALUE); - watchers.push_back(new ListWatcher(this, modename, rank)); + newconfigs.push_back(std::make_pair(modename, rank)); } + + stdalgo::delete_all(watchers); + watchers.clear(); + + for (NewConfigs::const_iterator i = newconfigs.begin(); i != newconfigs.end(); ++i) + watchers.push_back(new ListWatcher(this, i->first, i->second)); } ~ModuleHideList() |