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_restrictchans.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'src/modules/m_restrictchans.cpp') diff --git a/src/modules/m_restrictchans.cpp b/src/modules/m_restrictchans.cpp index 9c7ed1213..348beed2c 100644 --- a/src/modules/m_restrictchans.cpp +++ b/src/modules/m_restrictchans.cpp @@ -22,21 +22,26 @@ #include "inspircd.h" +typedef insp::flat_set AllowChans; + class ModuleRestrictChans : public Module { - insp::flat_set allowchans; + AllowChans allowchans; public: void ReadConfig(ConfigStatus& status) CXX11_OVERRIDE { - allowchans.clear(); + AllowChans newallows; ConfigTagList tags = ServerInstance->Config->ConfTags("allowchannel"); for(ConfigIter i = tags.first; i != tags.second; ++i) { - ConfigTag* tag = i->second; - std::string txt = tag->getString("name"); - allowchans.insert(txt); + const std::string name = i->second->getString("name"); + if (name.empty()) + throw ModuleException("Empty at " + i->second->getTagLocation()); + + newallows.insert(name); } + allowchans.swap(newallows); } ModResult OnUserPreJoin(LocalUser* user, Channel* chan, const std::string& cname, std::string& privs, const std::string& keygiven) CXX11_OVERRIDE -- cgit v1.3.1-10-gc9f91