diff options
author | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2010-01-19 02:28:30 +0000 |
---|---|---|
committer | danieldg <danieldg@e03df62e-2008-0410-955e-edbf42e46eb7> | 2010-01-19 02:28:30 +0000 |
commit | 0429d86a7afa7d5c1e27e48f27db0687d2688d87 (patch) | |
tree | b25b6bfbc41f67156a7a5b4d9b4cca34e3a9f26d /src | |
parent | 066cad22e48e111de9a993c9ebaddb275b773a75 (diff) |
Clean up some slow iterations
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@12300 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src')
-rw-r--r-- | src/inspircd.cpp | 1 | ||||
-rw-r--r-- | src/modmanager_static.cpp | 26 | ||||
-rw-r--r-- | src/modules/m_operjoin.cpp | 24 | ||||
-rw-r--r-- | src/modules/m_override.cpp | 25 | ||||
-rw-r--r-- | src/modules/m_permchannels.cpp | 13 |
5 files changed, 36 insertions, 53 deletions
diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 47f743df2..fe0ac0a11 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -247,7 +247,6 @@ bool InspIRCd::DaemonSeed() exit(0); } setsid (); - umask (007); printf("InspIRCd Process ID: \033[1;32m%lu\033[0m\n",(unsigned long)getpid()); signal(SIGTERM, InspIRCd::SetSignal); diff --git a/src/modmanager_static.cpp b/src/modmanager_static.cpp index e267a2c90..d9ee07a25 100644 --- a/src/modmanager_static.cpp +++ b/src/modmanager_static.cpp @@ -85,12 +85,19 @@ bool ModuleManager::Load(const char* name) return false; } -bool ModuleManager::Unload(Module* mod) -{ - return false; -} - namespace { + struct UnloadAction : public HandlerBase0<void> + { + Module* const mod; + UnloadAction(Module* m) : mod(m) {} + void Call() + { + ServerInstance->Modules->DoSafeUnload(mod); + ServerInstance->GlobalCulls.Apply(); + ServerInstance->GlobalCulls.AddItem(this); + } + }; + struct ReloadAction : public HandlerBase0<void> { Module* const mod; @@ -109,6 +116,14 @@ namespace { }; } +bool ModuleManager::Unload(Module* mod) +{ + if (!CanUnload(mod)) + return false; + ServerInstance->AtomicActions.AddAction(new UnloadAction(mod)); + return true; +} + void ModuleManager::Reload(Module* mod, HandlerBase1<void, bool>* callback) { if (CanUnload(mod)) @@ -127,6 +142,7 @@ void ModuleManager::LoadAll() { c = (*(**i).init)(); c->ModuleSourceFile = (**i).name; + c->ModuleDLLManager = NULL; Modules[(**i).name] = c; c->init(); FOREACH_MOD(I_OnLoadModule,OnLoadModule(c)); diff --git a/src/modules/m_operjoin.cpp b/src/modules/m_operjoin.cpp index 0c8975247..52901fe6f 100644 --- a/src/modules/m_operjoin.cpp +++ b/src/modules/m_operjoin.cpp @@ -20,7 +20,6 @@ class ModuleOperjoin : public Module private: std::string operChan; std::vector<std::string> operChans; - std::map<std::string, std::vector<std::string> > operTypeChans; // Channels specific to an oper type. bool override; int tokenize(const std::string &str, std::vector<std::string> &tokens) @@ -60,18 +59,6 @@ class ModuleOperjoin : public Module operChans.clear(); if (!operChan.empty()) tokenize(operChan,operChans); - - std::map<std::string, std::vector<std::string> >().swap(operTypeChans); - - int olines = conf.Enumerate("type"); - for (int index = 0; index < olines; ++index) - { - std::string chanList = conf.ReadValue("type", "autojoin", index); - if (!chanList.empty()) - { - tokenize(chanList, operTypeChans[conf.ReadValue("type", "name", index)]); - } - } } virtual ~ModuleOperjoin() @@ -92,12 +79,12 @@ class ModuleOperjoin : public Module if (ServerInstance->IsChannel(it->c_str(), ServerInstance->Config->Limits.ChanMax)) Channel::JoinUser(user, it->c_str(), override, "", false, ServerInstance->Time()); - std::map<std::string, std::vector<std::string> >::iterator i = operTypeChans.find(user->oper->name); - - if (i != operTypeChans.end()) + std::string chanList = IS_OPER(user)->getConfig("autojoin"); + if (!chanList.empty()) { - const std::vector<std::string>& list = i->second; - for (std::vector<std::string>::const_iterator it = list.begin(); it != list.end(); ++it) + std::vector<std::string> typechans; + tokenize(chanList, typechans); + for (std::vector<std::string>::const_iterator it = typechans.begin(); it != typechans.end(); ++it) { if (ServerInstance->IsChannel(it->c_str(), ServerInstance->Config->Limits.ChanMax)) { @@ -106,7 +93,6 @@ class ModuleOperjoin : public Module } } } - }; MODULE_INIT(ModuleOperjoin) diff --git a/src/modules/m_override.cpp b/src/modules/m_override.cpp index 982f65853..3131ab4b2 100644 --- a/src/modules/m_override.cpp +++ b/src/modules/m_override.cpp @@ -15,11 +15,8 @@ /* $ModDesc: Provides support for unreal-style oper-override */ -typedef std::map<std::string,std::string> override_t; - class ModuleOverride : public Module { - override_t overrides; bool RequireKey; bool NoisyOverride; @@ -42,15 +39,6 @@ class ModuleOverride : public Module // re-read our config options on a rehash NoisyOverride = Conf.ReadFlag("override", "noisy", 0); RequireKey = Conf.ReadFlag("override", "requirekey", 0); - - overrides.clear(); - - for (int j =0; j < Conf.Enumerate("type"); j++) - { - std::string typen = Conf.ReadValue("type","name",j); - std::string tokenlist = Conf.ReadValue("type","override",j); - overrides[typen] = tokenlist; - } } void On005Numeric(std::string &output) @@ -60,17 +48,10 @@ class ModuleOverride : public Module bool CanOverride(User* source, const char* token) { - // checks to see if the oper's type has <type:override> - override_t::iterator j = overrides.find(source->oper->name); - - if (j != overrides.end()) - { - // its defined or * is set, return its value as a boolean for if the token is set - return ((j->second.find(token, 0) != std::string::npos) || (j->second.find("*", 0) != std::string::npos)); - } + std::string tokenlist = source->oper->getConfig("override"); - // its not defined at all, count as false - return false; + // its defined or * is set, return its value as a boolean for if the token is set + return ((tokenlist.find(token, 0) != std::string::npos) || (tokenlist.find("*", 0) != std::string::npos)); } diff --git a/src/modules/m_permchannels.cpp b/src/modules/m_permchannels.cpp index fbbd38c15..e3d18cc33 100644 --- a/src/modules/m_permchannels.cpp +++ b/src/modules/m_permchannels.cpp @@ -217,15 +217,16 @@ public: * Process config-defined list of permanent channels. * -- w00t */ - ConfigReader MyConf; - permchannelsconf = MyConf.ReadValue("permchanneldb", "filename", "", 0, false); + permchannelsconf = ServerInstance->Config->ConfValue("permchanneldb")->getString("filename"); - for (int i = 0; i < MyConf.Enumerate("permchannels"); i++) + ConfigTagList permchannels = ServerInstance->Config->ConfTags("permchannels"); + for (ConfigIter i = permchannels.first; i != permchannels.second; ++i) { - std::string channel = MyConf.ReadValue("permchannels", "channel", i); - std::string topic = MyConf.ReadValue("permchannels", "topic", i); - std::string modes = MyConf.ReadValue("permchannels", "modes", i); + ConfigTag* tag = i->second; + std::string channel = tag->getString("channel"); + std::string topic = tag->getString("topic"); + std::string modes = tag->getString("modes"); if (channel.empty()) { |