From 0769519487fec4b024706d3d2ff665fc3d9401c6 Mon Sep 17 00:00:00 2001 From: brain Date: Thu, 12 Oct 2006 20:34:34 +0000 Subject: Only tick the timer when there are people doing /LIST, as suggested by special git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@5461 e03df62e-2008-0410-955e-edbf42e46eb7 --- src/modules/m_safelist.cpp | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) (limited to 'src') diff --git a/src/modules/m_safelist.cpp b/src/modules/m_safelist.cpp index 11976f91c..aebcc534e 100644 --- a/src/modules/m_safelist.cpp +++ b/src/modules/m_safelist.cpp @@ -136,24 +136,30 @@ class ListTimer : public InspTimer } } - timer = new ListTimer(ServerInstance,1); - ServerInstance->Timers->AddTimer(timer); + if (listusers.size()) + { + timer = new ListTimer(ServerInstance,1); + ServerInstance->Timers->AddTimer(timer); + } + else + { + timer = NULL; + } } }; class ModuleSafeList : public Module { - private: public: ModuleSafeList(InspIRCd* Me) : Module::Module(Me) { - timer = new ListTimer(ServerInstance,1); - ServerInstance->Timers->AddTimer(timer); + timer = NULL; } virtual ~ModuleSafeList() { - ServerInstance->Timers->DelTimer(timer); + if (timer) + ServerInstance->Timers->DelTimer(timer); } virtual Version GetVersion() @@ -223,7 +229,13 @@ class ModuleSafeList : public Module time_t* llt = new time_t; *llt = ServerInstance->Time(); user->Extend("safelist_last", llt); - + + if (!timer) + { + timer = new ListTimer(ServerInstance,1); + ServerInstance->Timers->AddTimer(timer); + } + return 1; } -- cgit v1.2.3