2003-05-26 09:18:31 +00:00
|
|
|
/* NeoStats - IRC Statistical Services
|
2004-01-14 11:36:37 +00:00
|
|
|
** Copyright (c) 1999-2004 Adam Rutter, Justin Hammond
|
2002-09-04 08:40:29 +00:00
|
|
|
** http://www.neostats.net/
|
|
|
|
**
|
|
|
|
** Portions Copyright (c) 2000-2001 ^Enigma^
|
|
|
|
**
|
|
|
|
** This program is free software; you can redistribute it and/or modify
|
|
|
|
** it under the terms of the GNU General Public License as published by
|
|
|
|
** the Free Software Foundation; either version 2 of the License, or
|
|
|
|
** (at your option) any later version.
|
|
|
|
**
|
|
|
|
** This program is distributed in the hope that it will be useful,
|
|
|
|
** but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
** GNU General Public License for more details.
|
|
|
|
**
|
|
|
|
** You should have received a copy of the GNU General Public License
|
|
|
|
** along with this program; if not, write to the Free Software
|
|
|
|
** Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
|
|
|
|
** USA
|
|
|
|
**
|
|
|
|
** NeoStats CVS Identification
|
2003-09-22 15:04:15 +00:00
|
|
|
** $Id$
|
2000-02-03 23:45:51 +00:00
|
|
|
*/
|
2003-06-13 13:11:50 +00:00
|
|
|
|
2000-02-03 23:45:51 +00:00
|
|
|
#include "stats.h"
|
|
|
|
#include "dl.h"
|
2003-04-11 09:26:31 +00:00
|
|
|
#include "log.h"
|
2003-09-15 10:39:39 +00:00
|
|
|
#include "conf.h"
|
2003-11-18 11:51:09 +00:00
|
|
|
#include "server.h"
|
2000-02-03 23:45:51 +00:00
|
|
|
|
|
|
|
static int midnight = 0;
|
2004-02-03 21:38:06 +00:00
|
|
|
#ifdef GOTSVSTIME
|
|
|
|
static int lastservertimesync = 0;
|
|
|
|
#endif
|
2000-02-03 23:45:51 +00:00
|
|
|
|
2003-10-14 15:29:41 +00:00
|
|
|
static int is_midnight (void);
|
|
|
|
static void TimerMidnight (void);
|
|
|
|
|
2003-07-30 13:58:22 +00:00
|
|
|
void
|
2003-10-14 15:29:41 +00:00
|
|
|
CheckTimers (void)
|
2000-02-03 23:45:51 +00:00
|
|
|
{
|
2003-11-18 11:51:09 +00:00
|
|
|
run_mod_timers();
|
2003-09-18 12:21:32 +00:00
|
|
|
SET_SEGV_LOCATION();
|
2003-11-18 11:51:09 +00:00
|
|
|
if (me.now - ping.last_sent > me.pingtime) {
|
|
|
|
PingServers ();
|
2003-09-15 10:39:39 +00:00
|
|
|
flush_keeper();
|
2003-11-03 13:57:11 +00:00
|
|
|
ping.last_sent = me.now;
|
|
|
|
#ifdef DEBUG
|
2003-11-18 11:51:09 +00:00
|
|
|
verify_hashes();
|
2003-11-03 13:57:11 +00:00
|
|
|
#endif
|
2003-04-10 15:26:58 +00:00
|
|
|
/* flush log files */
|
2003-07-30 13:58:22 +00:00
|
|
|
fflush (NULL);
|
2000-02-03 23:45:51 +00:00
|
|
|
}
|
2004-02-03 21:38:06 +00:00
|
|
|
#ifdef GOTSVSTIME
|
2004-02-03 21:54:11 +00:00
|
|
|
if (me.synced && me.setservertimes) {
|
2004-02-03 21:38:06 +00:00
|
|
|
if((me.now - lastservertimesync) > me.setservertimes) {
|
2004-02-03 21:54:11 +00:00
|
|
|
/* The above check does not need to be exact, but
|
|
|
|
setting times ought to be so reset me.now */
|
|
|
|
me.now = time(NULL);
|
2004-02-03 21:38:06 +00:00
|
|
|
ssvstime_cmd (me.now);
|
|
|
|
lastservertimesync = me.now;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2003-07-30 13:58:22 +00:00
|
|
|
if (is_midnight () == 1 && midnight == 0) {
|
|
|
|
TimerMidnight ();
|
2000-02-03 23:45:51 +00:00
|
|
|
midnight = 1;
|
|
|
|
} else {
|
2003-07-30 13:58:22 +00:00
|
|
|
if (midnight == 1 && is_midnight () == 0)
|
2000-02-03 23:45:51 +00:00
|
|
|
midnight = 0;
|
2003-06-13 13:11:50 +00:00
|
|
|
}
|
2000-02-03 23:45:51 +00:00
|
|
|
}
|
|
|
|
|
2003-11-18 11:51:09 +00:00
|
|
|
static void
|
2003-10-14 15:29:41 +00:00
|
|
|
TimerMidnight (void)
|
2000-02-03 23:45:51 +00:00
|
|
|
{
|
2003-11-03 13:57:11 +00:00
|
|
|
nlog (LOG_DEBUG1, LOG_CORE, "Its midnight!!! -> %s", sctime (me.now));
|
2003-10-14 15:03:55 +00:00
|
|
|
reset_logs ();
|
2000-02-03 23:45:51 +00:00
|
|
|
}
|
|
|
|
|
2003-10-14 15:29:41 +00:00
|
|
|
static int
|
|
|
|
is_midnight (void)
|
2000-02-03 23:45:51 +00:00
|
|
|
{
|
2003-11-18 11:51:09 +00:00
|
|
|
struct tm *ltm = localtime (&me.now);
|
2000-02-03 23:45:51 +00:00
|
|
|
|
2004-01-12 00:29:53 +00:00
|
|
|
if (ltm->tm_hour == 0 && ltm->tm_min == 0)
|
2000-02-03 23:45:51 +00:00
|
|
|
return 1;
|
2002-06-21 07:06:14 +00:00
|
|
|
|
2003-06-13 13:11:50 +00:00
|
|
|
return 0;
|
2000-02-03 23:45:51 +00:00
|
|
|
}
|