1 /* +------------------------------------+
2 * | Inspire Internet Relay Chat Daemon |
3 * +------------------------------------+
5 * InspIRCd is copyright (C) 2002-2006 ChatSpike-Dev.
7 * <brain@chatspike.net>
8 * <Craig@chatspike.net>
10 * Written by Craig Edwards, Craig McLure, and others.
11 * This program is free but copyrighted software; see
12 * the file COPYING for details.
14 * ---------------------------------------------------
19 #include "inspircd_config.h"
21 #include <sys/resource.h>
22 #include <sys/types.h>
23 #include <sys/socket.h>
24 #include <netinet/in.h>
40 #include "inspircd_io.h"
41 #include "inspstring.h"
42 #include "helperfuncs.h"
44 extern InspIRCd* ServerInstance;
45 extern ServerConfig* Config;
48 typedef std::vector<InspTimer*> timergroup;
49 typedef std::map<time_t, timergroup*> timerlist;
52 void TickTimers(time_t TIME)
54 timerlist::iterator found = Timers.find(TIME);
56 if (found != Timers.end())
58 timergroup* x = found->second;
60 * There are pending timers to trigger
62 for (timergroup::iterator y = x->begin(); y != x->end(); y++)
64 InspTimer* n = (InspTimer*)*y;
75 * Because some muppets may do odd things, and their ircd may lock up due
76 * to crappy 3rd party modules, or they may change their system time a bit,
77 * this accounts for shifts of up to 120 secs by looking behind for missed
78 * timers and executing them. This is only executed once every 5 secs.
79 * If you move your clock BACK, and your timers move further ahead as a result,
80 * then tough titty you'll just have to wait.
82 void TickMissedTimers(time_t TIME)
84 for (time_t n = TIME-1; n > TIME-120; n--)
86 timerlist::iterator found = Timers.find(n);
87 if (found != Timers.end())
89 timergroup* x = found->second;
90 for (timergroup::iterator y = x->begin(); y != x->end(); y++)
92 InspTimer* z = (InspTimer*)*y;
103 void AddTimer(InspTimer* T)
105 timergroup* x = NULL;
107 timerlist::iterator found = Timers.find(T->GetTimer());
109 if (found != Timers.end())
116 Timers[T->GetTimer()] = x;