diff options
| author | 2018-12-18 19:06:56 -0600 | |
|---|---|---|
| committer | 2018-12-19 01:06:56 +0000 | |
| commit | 4fbd6681fedbff9b4cb04cc774f785cbe8b5c35b (patch) | |
| tree | 9df58ec3e4cf2c191b4ae0051118606957d89db6 /src/listmode.cpp | |
| parent | Fix not propagating rehashes properly across the network. (diff) | |
| download | inspircd++-4fbd6681fedbff9b4cb04cc774f785cbe8b5c35b.tar.gz inspircd++-4fbd6681fedbff9b4cb04cc774f785cbe8b5c35b.tar.bz2 inspircd++-4fbd6681fedbff9b4cb04cc774f785cbe8b5c35b.zip | |
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/listmode.cpp')
| -rw-r--r-- | src/listmode.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/src/listmode.cpp b/src/listmode.cpp index 61fadcade..6b5fb13c5 100644 --- a/src/listmode.cpp +++ b/src/listmode.cpp @@ -62,8 +62,7 @@ void ListModeBase::DoRehash() { ConfigTagList tags = ServerInstance->Config->ConfTags(configtag); - limitlist oldlimits = chanlimits; - chanlimits.clear(); + limitlist newlimits; for (ConfigIter i = tags.first; i != tags.second; i++) { @@ -71,18 +70,25 @@ void ListModeBase::DoRehash() ConfigTag* c = i->second; ListLimit limit(c->getString("chan"), c->getUInt("limit", 0)); - if (limit.mask.size() && limit.limit > 0) - chanlimits.push_back(limit); + if (limit.mask.empty()) + throw ModuleException(InspIRCd::Format("<%s:chan> is empty at %s", configtag.c_str(), c->getTagLocation().c_str())); + + if (limit.limit <= 0) + throw ModuleException(InspIRCd::Format("<%s:limit> must be greater than 0, at %s", configtag.c_str(), c->getTagLocation().c_str())); + + newlimits.push_back(limit); } // Add the default entry. This is inserted last so if the user specifies a // wildcard record in the config it will take precedence over this entry. - chanlimits.push_back(ListLimit("*", DEFAULT_LIST_SIZE)); + newlimits.push_back(ListLimit("*", DEFAULT_LIST_SIZE)); // Most of the time our settings are unchanged, so we can avoid iterating the chanlist - if (oldlimits == chanlimits) + if (chanlimits == newlimits) return; + chanlimits.swap(newlimits); + const chan_hash& chans = ServerInstance->GetChans(); for (chan_hash::const_iterator i = chans.begin(); i != chans.end(); ++i) { |
