diff options
author | Adam <Adam@anope.org> | 2014-04-06 23:01:10 -0400 |
---|---|---|
committer | Adam <Adam@anope.org> | 2014-04-06 23:01:10 -0400 |
commit | 43219d3906a6a1b980319ae993c53f7606e438a6 (patch) | |
tree | 9fa29283a3e104069cc76362d7114c395e6cac5e /src/config.cpp | |
parent | 1f8dec4c242200403640ed72043899aa08cb81dd (diff) |
Do not apply module changes on rehash until after the new config has been applied. Fix renaming opertypes on reload.
Diffstat (limited to 'src/config.cpp')
-rw-r--r-- | src/config.cpp | 69 |
1 files changed, 40 insertions, 29 deletions
diff --git a/src/config.cpp b/src/config.cpp index 0275cb7f8..e402080db 100644 --- a/src/config.cpp +++ b/src/config.cpp @@ -525,47 +525,58 @@ Conf::Conf() : Block("") /* Check the user keys */ if (!options->Get<unsigned>("seed")) Log() << "Configuration option options:seed should be set. It's for YOUR safety! Remember that!"; +} - if (Config) +Conf::~Conf() +{ + for (unsigned i = 0; i < MyOperTypes.size(); ++i) + delete MyOperTypes[i]; + for (unsigned i = 0; i < Opers.size(); ++i) + delete Opers[i]; +} + +void Conf::Post(Conf *old) +{ + /* Apply module changes */ + for (unsigned i = 0; i < old->ModulesAutoLoad.size(); ++i) + if (std::find(this->ModulesAutoLoad.begin(), this->ModulesAutoLoad.end(), old->ModulesAutoLoad[i]) == this->ModulesAutoLoad.end()) + ModuleManager::UnloadModule(ModuleManager::FindModule(old->ModulesAutoLoad[i]), NULL); + for (unsigned i = 0; i < this->ModulesAutoLoad.size(); ++i) + if (std::find(old->ModulesAutoLoad.begin(), old->ModulesAutoLoad.end(), this->ModulesAutoLoad[i]) == old->ModulesAutoLoad.end()) + ModuleManager::LoadModule(this->ModulesAutoLoad[i], NULL); + + /* Apply opertype changes, as non-conf opers still point to the old oper types */ + for (unsigned i = Oper::opers.size(); i > 0; --i) { - /* Apply module chnages */ - for (unsigned i = 0; i < Config->ModulesAutoLoad.size(); ++i) - if (std::find(this->ModulesAutoLoad.begin(), this->ModulesAutoLoad.end(), Config->ModulesAutoLoad[i]) == this->ModulesAutoLoad.end()) - ModuleManager::UnloadModule(ModuleManager::FindModule(Config->ModulesAutoLoad[i]), NULL); - for (unsigned i = 0; i < this->ModulesAutoLoad.size(); ++i) - if (std::find(Config->ModulesAutoLoad.begin(), Config->ModulesAutoLoad.end(), this->ModulesAutoLoad[i]) == Config->ModulesAutoLoad.end()) - ModuleManager::LoadModule(this->ModulesAutoLoad[i], NULL); - - /* Apply opertype changes, as non-conf opers still point to the old oper types */ - for (unsigned i = Oper::opers.size(); i > 0; --i) + Oper *o = Oper::opers[i - 1]; + + /* Oper's type is in the old config, so update it */ + if (std::find(old->MyOperTypes.begin(), old->MyOperTypes.end(), o->ot) != old->MyOperTypes.end()) { - Oper *o = Oper::opers[i - 1]; + OperType *ot = o->ot; + o->ot = NULL; + + for (unsigned j = 0; j < MyOperTypes.size(); ++j) + if (ot->GetName() == MyOperTypes[j]->GetName()) + o->ot = MyOperTypes[j]; - /* Oper's type is in the old config, so update it */ - if (std::find(Config->MyOperTypes.begin(), Config->MyOperTypes.end(), o->ot) != Config->MyOperTypes.end()) + if (o->ot == NULL) { - OperType *ot = o->ot; - o->ot = NULL; + /* Oper block has lost type */ + std::vector<Oper *>::iterator it = std::find(old->Opers.begin(), old->Opers.end(), o); + if (it != old->Opers.end()) + old->Opers.erase(it); - for (unsigned j = 0; j < MyOperTypes.size(); ++j) - if (ot->GetName() == MyOperTypes[j]->GetName()) - o->ot = MyOperTypes[j]; + it = std::find(this->Opers.begin(), this->Opers.end(), o); + if (it != this->Opers.end()) + this->Opers.erase(it); - if (o->ot == NULL) - delete o; /* Oper block has lost type */ + delete o; } } } } -Conf::~Conf() -{ - for (unsigned i = 0; i < MyOperTypes.size(); ++i) - delete MyOperTypes[i]; - for (unsigned i = 0; i < Opers.size(); ++i) - delete Opers[i]; -} - Block *Conf::GetModule(Module *m) { if (!m) |