Skip to content

Commit

Permalink
Fix timeouts when changing maps. Dont check timeout for a few secs af…
Browse files Browse the repository at this point in the history
…ter map change.
  • Loading branch information
geneotech committed Jul 28, 2024
1 parent b204aae commit 782d526
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 15 deletions.
32 changes: 18 additions & 14 deletions src/application/setups/server/server_setup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2398,6 +2398,8 @@ bool server_setup::apply(const server_vars& new_vars, const bool first_time) {
vars = new_vars;

if (reload_arena) {
dont_check_timeouts_until = server_time + 6.0;

write_vars_to_disk_once = true;

try {
Expand Down Expand Up @@ -2847,20 +2849,22 @@ void server_setup::advance_clients_state() {
automove_to_spectators_if_afk(client_id, c);
}

if (c.should_kick_due_to_network_timeout(vars, server_time)) {
if (!c.is_web_client_paused()) {
const auto timeout_secs = c.get_client_network_timeout_secs(vars);
LOG_NVPS(c.last_valid_payload_time, server_time, timeout_secs);

if (c.is_web_client()) {
LOG("Pausing the web client due to timeout.");
c.web_client_paused = client_pause_state::PAUSED;
c.entropies_since_pause = 0;
c.reset_solvable_stream();
}
else {
kick(client_id, "Connection timed out!");
c.kick_no_linger = true;
if (server_time >= dont_check_timeouts_until) {
if (c.should_kick_due_to_network_timeout(vars, server_time)) {
if (!c.is_web_client_paused()) {
const auto timeout_secs = c.get_client_network_timeout_secs(vars);
LOG_NVPS(c.last_valid_payload_time, server_time, timeout_secs);

if (c.is_web_client()) {
LOG("Pausing the web client due to timeout.");
c.web_client_paused = client_pause_state::PAUSED;
c.entropies_since_pause = 0;
c.reset_solvable_stream();
}
else {
kick(client_id, "Connection timed out!");
c.kick_no_linger = true;
}
}
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/application/setups/server/server_setup.h
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,8 @@ class server_setup :
net_time_t when_last_used_map_command = 0;
net_time_t when_last_changed_map_due_to_idle = 0;

net_time_t dont_check_timeouts_until = 0;

double tell_me_my_address_stamp = 0;

static bool is_webrtc_only();
Expand Down
6 changes: 5 additions & 1 deletion src/game/modes/arena_mode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -493,10 +493,14 @@ void arena_mode::erase_player(input_type in, const logic_step step, const mode_p
}
}

bool arena_mode::should_suspend_instead_of_remove(const const_input_type in) const {
bool arena_mode::is_ranked_live_and_not_summary(const const_input_type in) const {
return is_ranked_live() && !is_last_summary(in);
}

bool arena_mode::should_suspend_instead_of_remove(const const_input_type in) const {
return is_ranked_live_and_not_summary(in);
}

void arena_mode::notify_ranked_banned(
const arena_mode_player& banned_player,
const mode_player_id& id_when_suspended,
Expand Down
1 change: 1 addition & 0 deletions src/game/modes/arena_mode.h
Original file line number Diff line number Diff line change
Expand Up @@ -754,6 +754,7 @@ class arena_mode {
return suspended_players.size();
};

bool is_ranked_live_and_not_summary(const const_input in) const;
bool should_suspend_instead_of_remove(const const_input in) const;
float find_suspended_time_left(const const_input in) const;
float get_match_unfreezes_in_secs() const;
Expand Down

0 comments on commit 782d526

Please sign in to comment.