diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-01-08 18:42:13 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2007-01-08 18:42:13 +0000 |
commit | 2fe4636fa44ad48b801d0e38b892c0e47998327d (patch) | |
tree | eceb91cda854b4fd8ab00e33c0d327ed88c33e01 /src/timer.cpp | |
parent | a3bda51ef1095c92499b69a14273b4adf962ab1e (diff) |
Add repeating timers, and make an hourly prune of the dns cache, otherwise a cache entry might not be cleared until a user with that ip comes back!
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@6264 e03df62e-2008-0410-955e-edbf42e46eb7
Diffstat (limited to 'src/timer.cpp')
-rw-r--r-- | src/timer.cpp | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/src/timer.cpp b/src/timer.cpp index 04ff1c15b..6be7aa06c 100644 --- a/src/timer.cpp +++ b/src/timer.cpp @@ -28,7 +28,14 @@ void TimerManager::TickTimers(time_t TIME) { InspTimer* n = *y; n->Tick(TIME); - DELETE(n); + if (n->GetRepeat()) + { + AddTimer(n, n->GetSecs()); + } + else + { + DELETE(n); + } } Timers.erase(found); @@ -78,7 +85,14 @@ void TimerManager::TickMissedTimers(time_t TIME) { InspTimer* z = *y; z->Tick(TIME); - DELETE(z); + if (z->GetRepeat()) + { + AddTimer(z, z->GetSecs()); + } + else + { + DELETE(z); + } } Timers.erase(found); @@ -87,12 +101,18 @@ void TimerManager::TickMissedTimers(time_t TIME) } } -void TimerManager::AddTimer(InspTimer* T) +void TimerManager::AddTimer(InspTimer* T, long secs_from_now) { timergroup* x = NULL; - timerlist::iterator found = Timers.find(T->GetTimer()); - + int time_to_trigger = 0; + if (!secs_from_now) + time_to_trigger = T->GetTimer(); + else + time_to_trigger = secs_from_now + time(NULL); + + timerlist::iterator found = Timers.find(time_to_trigger); + if (found != Timers.end()) { x = found->second; @@ -100,7 +120,7 @@ void TimerManager::AddTimer(InspTimer* T) else { x = new timergroup; - Timers[T->GetTimer()] = x; + Timers[time_to_trigger] = x; } x->push_back(T); |