From 0c375a44426df54311882a716cfdc4f91f9e5862 Mon Sep 17 00:00:00 2001 From: nohar Date: Mon, 23 May 2005 23:05:11 +0000 Subject: [PATCH] gory throttle avoidance. may drop --- src/irc.c | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/irc.c b/src/irc.c index 9f05f32..1700a93 100644 --- a/src/irc.c +++ b/src/irc.c @@ -21,6 +21,8 @@ #include "connection.h" #include "md5.h" +#define S_CONN_DELAY (10) + extern int sighup; static int irc_join(struct link_server *server, struct line *line); @@ -1941,12 +1943,18 @@ void irc_main(connection_t *inc, list_t *ll) /* Compute timeouts for next reconnections and lagouts */ if (timeleft == 0) { + static int throttle_prot = S_CONN_DELAY - 1; + timeleft = 1000; - /* Lauch one reconnection at a time */ - if ((link = list_remove_first(&reconnectl))) { - conn = irc_server_connect(link); - list_add_last(&connl, conn); + if (++throttle_prot == S_CONN_DELAY) { + throttle_prot = 0; + + /* Lauch one reconnection at a time */ + if ((link = list_remove_first(&reconnectl))) { + conn = irc_server_connect(link); + list_add_last(&connl, conn); + } } /* log flushs */