From 0f8280ed519b511c4d9cea8f34de2dd87c7d5fac Mon Sep 17 00:00:00 2001 From: Kevin Easton Date: Tue, 12 May 2015 22:39:30 +1000 Subject: [PATCH] Prevent indefinite wait if CONNECT_DELAY is set to zero set_server_bits() now returns -1 for "no timeout", so 0 is a legitimate return value. io() should only update real_timeout from server_timeout if server_timeout is not -1 (real_timeout == -1 ends up meaning "wait indefinitely"). Note that if you set CONNECT_DELAY to zero you get a lag check ping sent off first thing in the server connection, this should be fixed. --- source/irc.c | 4 ++-- source/server.c | 4 +--- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/source/irc.c b/source/irc.c index a7f1edd..11612e5 100644 --- a/source/irc.c +++ b/source/irc.c @@ -1271,7 +1271,7 @@ void BX_io (const char *what) else real_timeout = clock_timeout; - if(server_timeout && (server_timeout == -1 || server_timeout < real_timeout)) + if (server_timeout >= 0 && server_timeout < real_timeout) real_timeout = server_timeout; time_ptr = &my_timer; @@ -1288,7 +1288,7 @@ void BX_io (const char *what) switch ((rc = new_select(&rd, &wd, time_ptr))) { case 0: - if(server_timeout) + if (server_timeout >= 0) do_idle_server(); break; case -1: diff --git a/source/server.c b/source/server.c index f117564..b7e24b3 100644 --- a/source/server.c +++ b/source/server.c @@ -230,7 +230,7 @@ void close_unattached_servers(void) long set_server_bits (fd_set *rd, fd_set *wr) { int i; - long timeout = 0; + long timeout = -1; for (i = 0; i < number_of_servers; i++) { @@ -240,8 +240,6 @@ long set_server_bits (fd_set *rd, fd_set *wr) * return in milliseconds. */ timeout = get_int_var(CONNECT_DELAY_VAR)*1000; - if(!timeout) - timeout = -1; } if (server_list[i].read > -1)