summaryrefslogtreecommitdiff
path: root/src/modules.c
diff options
context:
space:
mode:
authorAdam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864>2009-10-02 22:19:19 +0000
committerAdam- <Adam-@5417fbe8-f217-4b02-8779-1006273d7864>2009-10-02 22:19:19 +0000
commitdc4b9afebbea5c8ca2d5b86c84411153b1622f71 (patch)
tree92ca6661ccceea15a215e77f3879b4c036ada67c /src/modules.c
parent85b409df8577e2433724a056564ab62ff72c4c89 (diff)
Properly remove old callbacks from modules internal list of callbacks list, and cleaned up some of the timers code
git-svn-id: http://anope.svn.sourceforge.net/svnroot/anope/trunk@2524 5417fbe8-f217-4b02-8779-1006273d7864
Diffstat (limited to 'src/modules.c')
-rw-r--r--src/modules.c29
1 files changed, 18 insertions, 11 deletions
diff --git a/src/modules.c b/src/modules.c
index e33bc863a..b7af6acf5 100644
--- a/src/modules.c
+++ b/src/modules.c
@@ -625,6 +625,19 @@ int destroyMessage(Message * m)
*/
void Module::AddCallBack(Timer *t)
{
+ /* Remove no longer valid Timers from the modules internal list */
+ std::list<Timer *>::iterator it, it2;
+ for (it = this->CallBacks.begin(); it != this->CallBacks.end(); it = it2)
+ {
+ it2 = it;
+ ++it2;
+
+ if (!TimerManager::IsTimer(*it))
+ {
+ this->CallBacks.erase(it);
+ }
+ }
+
this->CallBacks.push_back(t);
}
@@ -634,19 +647,13 @@ void Module::AddCallBack(Timer *t)
*/
bool Module::DelCallBack(Timer *t)
{
- std::list<Timer *>::iterator it;
- Timer *t2;
+ std::list<Timer *>::iterator it = std::find(this->CallBacks.begin(), this->CallBacks.end(), t);
- for (it = this->CallBacks.begin(); it != this->CallBacks.end(); ++it)
+ if (it != this->CallBacks.end())
{
- t2 = *it;
-
- if (t == t2)
- {
- TimerManager::DelTimer(t2);
- this->CallBacks.erase(it);
- return true;
- }
+ TimerManager::DelTimer(*it);
+ this->CallBacks.erase(it);
+ return true;
}
return false;