diff options
author | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-02-23 20:35:52 +0000 |
---|---|---|
committer | brain <brain@e03df62e-2008-0410-955e-edbf42e46eb7> | 2006-02-23 20:35:52 +0000 |
commit | 991bc1d3cf461e828b58864888593e6f09a3ac0c (patch) | |
tree | f07916235aada2131a83570eab865492908cb442 | |
parent | 612bb6602616f7ec5bd2c983500336f7eff419e0 (diff) |
Look-behind for missed timers up to 2 minutes (if your ircd has hung for 2 minutes, or your clock drift is > 2 mins, you have bigger fish to fry, like dead network or TS split)
git-svn-id: http://svn.inspircd.org/repository/trunk/inspircd@3310 e03df62e-2008-0410-955e-edbf42e46eb7
-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; |