1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd: (C) 2002-2007 InspIRCd Development Team
6 * See: http://www.inspircd.org/wiki/index.php/Credits
8 * This program is free but copyrighted software; see
9 * the file COPYING for details.
11 * ---------------------------------------------------
17 void TimerManager::TickTimers(time_t TIME)
19 timerlist::iterator found = Timers.find(TIME);
21 if (found != Timers.end())
23 timergroup* x = found->second;
25 * There are pending timers to trigger
27 for (timergroup::iterator y = x->begin(); y != x->end(); y++)
33 AddTimer(n, n->GetSecs());
46 void TimerManager::DelTimer(InspTimer* T)
48 timerlist::iterator found = Timers.find(T->GetTimer());
50 if (found != Timers.end())
52 timergroup* x = found->second;
53 for (timergroup::iterator y = x->begin(); y != x->end(); y++)
69 * Because some muppets may do odd things, and their ircd may lock up due
70 * to crappy 3rd party modules, or they may change their system time a bit,
71 * this accounts for shifts of up to 120 secs by looking behind for missed
72 * timers and executing them. This is only executed once every 5 secs.
73 * If you move your clock BACK, and your timers move further ahead as a result,
74 * then tough titty you'll just have to wait.
76 void TimerManager::TickMissedTimers(time_t TIME)
78 for (time_t n = TIME-1; n > TIME-120; n--)
80 timerlist::iterator found = Timers.find(n);
81 if (found != Timers.end())
83 timergroup* x = found->second;
84 for (timergroup::iterator y = x->begin(); y != x->end(); y++)
90 AddTimer(z, z->GetSecs());
104 void TimerManager::AddTimer(InspTimer* T, long secs_from_now)
106 timergroup* x = NULL;
108 int time_to_trigger = 0;
110 time_to_trigger = T->GetTimer();
112 time_to_trigger = secs_from_now + time(NULL);
114 timerlist::iterator found = Timers.find(time_to_trigger);
116 if (found != Timers.end())
123 Timers[time_to_trigger] = x;