From 991bc1d3cf461e828b58864888593e6f09a3ac0c Mon Sep 17 00:00:00 2001 From: brain Date: Thu, 23 Feb 2006 20:35:52 +0000 Subject: 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 --- include/timer.h | 1 + src/inspircd.cpp | 1 + src/timer.cpp | 21 +++++++++++++++++++++ 3 files changed, 23 insertions(+) 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; -- cgit v1.2.3