diff options
-rw-r--r-- | include/timer.h | 1 | ||||
-rw-r--r-- | src/inspircd.cpp | 1 | ||||
-rw-r--r-- | src/timer.cpp | 21 |
3 files changed, 23 insertions, 0 deletions
diff --git a/include/timer.h b/include/timer.h index 1538fbfb1..b75f3776f 100644 --- a/include/timer.h +++ b/include/timer.h @@ -35,4 +35,5 @@ class InspTimer void TickTimers(time_t TIME); void AddTimer(InspTimer* T); +void TickMissedTimers(time_t TIME); diff --git a/src/inspircd.cpp b/src/inspircd.cpp index 72a02d3bc..ee30ba4e9 100644 --- a/src/inspircd.cpp +++ b/src/inspircd.cpp @@ -641,6 +641,7 @@ int InspIRCd::Run() { expire_lines(); FOREACH_MOD(I_OnBackgroundTimer,OnBackgroundTimer(TIME)); + TickMissedTimers(TIME); expire_run = true; continue; } diff --git a/src/timer.cpp b/src/timer.cpp index b804920e5..7d9c9f3df 100644 --- a/src/timer.cpp +++ b/src/timer.cpp @@ -65,6 +65,27 @@ void TickTimers(time_t TIME) } } +void TickMissedTimers(time_t TIME) +{ + for (time_t n = TIME-1; time_t n > TIME-120; n--) + { + timerlist::iterator found = Timers.find(n); + if (found != Timers.end()) + { + timergroup* x = found->second; + for (timergroup::iterator y = x->begin(); y != x->end(); y++) + { + InspTimer* z = (InspTimer*)*y; + z->Tick(TIME); + delete z; + } + + Timers.erase(found); + delete x; + } + } +} + void AddTimer(InspTimer* T) { timergroup* x = NULL; |