diff options
-rw-r--r-- | src/modules/m_spanningtree/cachetimer.cpp | 36 | ||||
-rw-r--r-- | src/modules/m_spanningtree/main.cpp | 11 | ||||
-rw-r--r-- | src/modules/m_spanningtree/main.h | 1 | ||||
-rw-r--r-- | src/modules/m_spanningtree/resolvers.cpp | 12 | ||||
-rw-r--r-- | src/modules/m_spanningtree/utils.cpp | 4 | ||||
-rw-r--r-- | src/modules/m_spanningtree/utils.h | 3 |
6 files changed, 21 insertions, 46 deletions
diff --git a/src/modules/m_spanningtree/cachetimer.cpp b/src/modules/m_spanningtree/cachetimer.cpp deleted file mode 100644 index 4fdc7056f..000000000 --- a/src/modules/m_spanningtree/cachetimer.cpp +++ /dev/null @@ -1,36 +0,0 @@ -/* - * InspIRCd -- Internet Relay Chat Daemon - * - * Copyright (C) 2008 Craig Edwards <craigedwards@brainbox.cc> - * - * This file is part of InspIRCd. InspIRCd is free software: you can - * redistribute it and/or modify it under the terms of the GNU General Public - * License as published by the Free Software Foundation, version 2. - * - * This program is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS - * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more - * details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - - -#include "inspircd.h" - -#include "cachetimer.h" -#include "utils.h" - -/* $ModDep: m_spanningtree/cachetimer.h m_spanningtree/utils.h */ - -CacheRefreshTimer::CacheRefreshTimer(SpanningTreeUtilities* Util) : Timer(3600, ServerInstance->Time(), true), Utils(Util) -{ -} - -bool CacheRefreshTimer::Tick(time_t TIME) -{ - Utils->RefreshIPCache(); - return true; -} - diff --git a/src/modules/m_spanningtree/main.cpp b/src/modules/m_spanningtree/main.cpp index 029f5e888..6cca6462c 100644 --- a/src/modules/m_spanningtree/main.cpp +++ b/src/modules/m_spanningtree/main.cpp @@ -27,7 +27,6 @@ #include "socket.h" #include "xline.h" -#include "cachetimer.h" #include "resolvers.h" #include "main.h" #include "utils.h" @@ -38,10 +37,8 @@ #include "protocolinterface.h" ModuleSpanningTree::ModuleSpanningTree() + : commands(NULL), Utils(NULL) { - Utils = new SpanningTreeUtilities(this); - commands = new SpanningTreeCommands(this); - RefreshTimer = NULL; } SpanningTreeCommands::SpanningTreeCommands(ModuleSpanningTree* module) @@ -54,6 +51,8 @@ SpanningTreeCommands::SpanningTreeCommands(ModuleSpanningTree* module) void ModuleSpanningTree::init() { + Utils = new SpanningTreeUtilities(this); + commands = new SpanningTreeCommands(this); ServerInstance->Modules->AddService(commands->rconnect); ServerInstance->Modules->AddService(commands->rsquit); ServerInstance->Modules->AddService(commands->svsjoin); @@ -70,8 +69,6 @@ void ModuleSpanningTree::init() ServerInstance->Modules->AddService(commands->fhost); ServerInstance->Modules->AddService(commands->fident); ServerInstance->Modules->AddService(commands->fname); - RefreshTimer = new CacheRefreshTimer(this, Utils); - ServerInstance->Timers->AddTimer(RefreshTimer); Implementation eventlist[] = { @@ -906,8 +903,6 @@ void ModuleSpanningTree::ProtoSendMetaData(void* opaque, Extensible* target, con CullResult ModuleSpanningTree::cull() { Utils->cull(); - ServerInstance->Timers->DelTimer(RefreshTimer); - delete RefreshTimer; return this->Module::cull(); } diff --git a/src/modules/m_spanningtree/main.h b/src/modules/m_spanningtree/main.h index 8cc2d984f..7401274c3 100644 --- a/src/modules/m_spanningtree/main.h +++ b/src/modules/m_spanningtree/main.h @@ -56,7 +56,6 @@ class ModuleSpanningTree : public Module public: SpanningTreeUtilities* Utils; - CacheRefreshTimer *RefreshTimer; /** Set to true if inside a spanningtree call, to prevent sending * xlines and other things back to their source */ diff --git a/src/modules/m_spanningtree/resolvers.cpp b/src/modules/m_spanningtree/resolvers.cpp index b0be2cd60..ff5544064 100644 --- a/src/modules/m_spanningtree/resolvers.cpp +++ b/src/modules/m_spanningtree/resolvers.cpp @@ -20,6 +20,7 @@ #include "inspircd.h" +#include "cachetimer.h" #include "resolvers.h" #include "main.h" #include "utils.h" @@ -108,3 +109,14 @@ void SecurityIPResolver::OnError(ResolverError e, const std::string &errormessag ServerInstance->Logs->Log("m_spanningtree",LOG_DEFAULT,"Could not resolve IP associated with Link '%s': %s", MyLink->Name.c_str(),errormessage.c_str()); } + +CacheRefreshTimer::CacheRefreshTimer(SpanningTreeUtilities* Util) + : Timer(3, ServerInstance->Time(), true), Utils(Util) +{ +} + +bool CacheRefreshTimer::Tick(time_t TIME) +{ + Utils->RefreshIPCache(); + return true; +} diff --git a/src/modules/m_spanningtree/utils.cpp b/src/modules/m_spanningtree/utils.cpp index cb8a39638..18e9d72b8 100644 --- a/src/modules/m_spanningtree/utils.cpp +++ b/src/modules/m_spanningtree/utils.cpp @@ -126,8 +126,10 @@ TreeServer* SpanningTreeUtilities::FindServerID(const std::string &id) return NULL; } -SpanningTreeUtilities::SpanningTreeUtilities(ModuleSpanningTree* C) : Creator(C) +SpanningTreeUtilities::SpanningTreeUtilities(ModuleSpanningTree* C) + : RefreshTimer(this), Creator(C) { + ServerInstance->Timers->AddTimer(&RefreshTimer); ServerInstance->Logs->Log("m_spanningtree",LOG_DEBUG,"***** Using SID for hash: %s *****", ServerInstance->Config->GetSID().c_str()); this->TreeRoot = new TreeServer(this, ServerInstance->Config->ServerName, ServerInstance->Config->ServerDesc, ServerInstance->Config->GetSID()); diff --git a/src/modules/m_spanningtree/utils.h b/src/modules/m_spanningtree/utils.h index 36c161287..a2566c0c8 100644 --- a/src/modules/m_spanningtree/utils.h +++ b/src/modules/m_spanningtree/utils.h @@ -23,6 +23,7 @@ #pragma once #include "inspircd.h" +#include "cachetimer.h" /* Foward declarations */ class TreeServer; @@ -48,6 +49,8 @@ class SpanningTreeUtilities : public classbase */ std::string ConstructLine(const std::string& prefix, const std::string& command, const parameterlist& params); + CacheRefreshTimer RefreshTimer; + public: /** Creator module */ |