qstat.c
/* Functions for figuring timeouts and when to give up
 * Returns 1 if the query is done (server may be freed) and 0 if not.
 */
Functions for figuring timeouts and when to give up
Returns 1 if the query is done (server may be freed) and 0 if not.
Functions for figuring timeouts and when to give up Returns 1 if the query is done ( server may be freed ) and 0 if not .
int cleanup_qserver(struct qserver *server, int force)
{
	int close_it = force;
	debug( 3, "cleanup_qserver %p, %d", server, force );
	if ( server->server_name == NULL )
	{
		debug(3, "server has no name, forcing close");
		close_it = 1;
		if (server->type->id &MASTER_SERVER && server->master_pkt != NULL)
		{
			server->server_name = MASTER;
		}
		else
		{
			server->server_name = TIMEOUT;
			num_servers_timed_out++;
		}
	}
	else if (server->type->flags &TF_SINGLE_QUERY)
	{
		debug(3, "TF_SINGLE_QUERY, forcing close");
		close_it = 1;
	}
	else if (server->next_rule == NO_SERVER_RULES && server->next_player_info >= server->num_players)
	{
		debug(3, "no server rules and next_player_info >= num_players, forcing close");
		close_it = 1;
	}
	debug(3, "close_it %d", close_it);
	if (close_it)
	{
		if (server->saved_data.data)
		{
			SavedData *sdata = server->saved_data.next;
			free(server->saved_data.data);
			server->saved_data.data = NULL;
			while (sdata != NULL)
			{
				SavedData *next;
				free(sdata->data);
				next = sdata->next;
				free(sdata);
				sdata = next;
			}
			server->saved_data.next = NULL;
		}
		qserver_disconnect(server);
		if (server->server_name != TIMEOUT)
		{
			num_servers_returned++;
			if (server->server_name != DOWN)
			{
				num_players_total += server->num_players;
				max_players_total += server->max_players;
			}
		}
		if (server->server_name == TIMEOUT || server->server_name == DOWN)
		{
			server->ping_total = 999999;
		}
		if (server->type->master)
		{
			waiting_for_masters--;
			if (waiting_for_masters == 0)
			{
				add_servers_from_masters();
			}
		}
		if (!server_sort)
		{
			display_server(server);
		}
		return 1;
	}
	return 0;
}
int cleanup_qserver ( struct qserver * server , int force ) { int close_it = force ; debug ( 3 , " " , server , force ) ; if ( server -> server_name == NULL ) { debug ( 3 , " " ) ; close_it = 1 ; if ( server -> type -> id & MASTER_SERVER && server -> master_pkt != NULL ) { server -> server_name = MASTER ; } else { server -> server_name = TIMEOUT ; num_servers_timed_out ++ ; } } else if ( server -> type -> flags & TF_SINGLE_QUERY ) { debug ( 3 , " " ) ; close_it = 1 ; } else if ( server -> next_rule == NO_SERVER_RULES && server -> next_player_info >= server -> num_players ) { debug ( 3 , " " ) ; close_it = 1 ; } debug ( 3 , " " , close_it ) ; if ( close_it ) { if ( server -> saved_data . data ) { SavedData * sdata = server -> saved_data . next ; free ( server -> saved_data . data ) ; server -> saved_data . data = NULL ; while ( sdata != NULL ) { SavedData * next ; free ( sdata -> data ) ; next = sdata -> next ; free ( sdata ) ; sdata = next ; } server -> saved_data . next = NULL ; } qserver_disconnect ( server ) ; if ( server -> server_name != TIMEOUT ) { num_servers_returned ++ ; if ( server -> server_name != DOWN ) { num_players_total += server -> num_players ; max_players_total += server -> max_players ; } } if ( server -> server_name == TIMEOUT || server -> server_name == DOWN ) { server -> ping_total = 999999 ; } if ( server -> type -> master ) { waiting_for_masters -- ; if ( waiting_for_masters == 0 ) { add_servers_from_masters ( ) ; } } if ( ! server_sort ) { display_server ( server ) ; } return 1 ; } return 0 ; }
Functions for figuring timeouts and when to give up
 Returns 1 if the query is done (server may be freed) and 0 if not.
Functions for figuring timeouts and when to give up Returns 1 if the query is done ( server may be freed ) and 0 if not .