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.
This commit is contained in:
Kevin Easton
2015-05-12 22:39:30 +10:00
parent 72f5536121
commit 0f8280ed51
2 changed files with 3 additions and 5 deletions

View File

@@ -1271,7 +1271,7 @@ void BX_io (const char *what)
else else
real_timeout = clock_timeout; 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; real_timeout = server_timeout;
time_ptr = &my_timer; time_ptr = &my_timer;
@@ -1288,7 +1288,7 @@ void BX_io (const char *what)
switch ((rc = new_select(&rd, &wd, time_ptr))) switch ((rc = new_select(&rd, &wd, time_ptr)))
{ {
case 0: case 0:
if(server_timeout) if (server_timeout >= 0)
do_idle_server(); do_idle_server();
break; break;
case -1: case -1:

View File

@@ -230,7 +230,7 @@ void close_unattached_servers(void)
long set_server_bits (fd_set *rd, fd_set *wr) long set_server_bits (fd_set *rd, fd_set *wr)
{ {
int i; int i;
long timeout = 0; long timeout = -1;
for (i = 0; i < number_of_servers; i++) 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. * return in milliseconds.
*/ */
timeout = get_int_var(CONNECT_DELAY_VAR)*1000; timeout = get_int_var(CONNECT_DELAY_VAR)*1000;
if(!timeout)
timeout = -1;
} }
if (server_list[i].read > -1) if (server_list[i].read > -1)