Permalink
Browse files

Fix minutely hook to be called for all missed minutes. Fixes #308

Found by: maimizuno / Patch by: Cizzle

* Minutely hook now able to display minutes > 60 (previously only displayed mod 60)
  • Loading branch information...
1 parent 20eb6a8 commit 39ee2eb382def5f598a53546761994c729b60507 @Cizzle Cizzle committed with vanosg Jan 27, 2017
Showing with 11 additions and 9 deletions.
  1. +9 −7 src/main.c
  2. +2 −2 src/patch.h
View
@@ -550,7 +550,7 @@ void backup_userfile(void)
}
/* Timer info */
-static int lastmin = 99;
+static time_t lastmin;
static time_t then;
static struct tm nowtm;
@@ -562,6 +562,7 @@ static void core_secondly()
{
static int cnt = 0;
int miltime;
+ time_t nowmins;
do_check_timers(&utimer); /* Secondly timers */
cnt++;
@@ -577,20 +578,21 @@ static void core_secondly()
}
}
egg_memcpy(&nowtm, localtime(&now), sizeof(struct tm));
- if (nowtm.tm_min != lastmin) {
+ nowmins = time(NULL) / 60;
+ if (nowmins > lastmin) {
int i = 0;
/* Once a minute */
- lastmin = (lastmin + 1) % 60;
+ ++lastmin;
call_hook(HOOK_MINUTELY);
check_expired_ignores();
autolink_cycle(NULL); /* Attempt autolinks */
/* In case for some reason more than 1 min has passed: */
- while (nowtm.tm_min != lastmin) {
+ while (nowmins != lastmin) {
/* Timer drift, dammit */
- debug2("timer: drift (lastmin=%d, now=%d)", lastmin, nowtm.tm_min);
+ debug2("timer: drift (lastmin=%d, nowmins=%d)", lastmin, nowmins);
i++;
- lastmin = (lastmin + 1) % 60;
+ ++lastmin;
call_hook(HOOK_MINUTELY);
}
if (i > 1)
@@ -1050,7 +1052,7 @@ int main(int arg_c, char **arg_v)
now = time(NULL);
chanset = NULL;
egg_memcpy(&nowtm, localtime(&now), sizeof(struct tm));
- lastmin = nowtm.tm_min;
+ lastmin = now / 60;
srandom((unsigned int) (now % (getpid() + getppid())));
init_mem();
init_language(1);
View
@@ -39,12 +39,12 @@ patch("Git"); /* Git version */
*
*
*/
-patch("1485398611"); /* current unixtime */
+patch("1485483674"); /* current unixtime */
/*
*
*
*/
-patch("vhostreply");
+patch("timerdrift");
/*
*
*

0 comments on commit 39ee2eb

Please sign in to comment.