mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-02 13:45:51 +00:00
Add the minimum ping interval to the ping timeout.
Define this interval as a constant in network.hpp
This commit is contained in:
parent
35df198854
commit
8f2f43d3ea
@ -71,7 +71,7 @@
|
||||
default=0
|
||||
min=0
|
||||
max=60
|
||||
step=1
|
||||
step=5
|
||||
[/advanced_preference]
|
||||
|
||||
[advanced_preference]
|
||||
|
@ -160,7 +160,7 @@ static void check_timeout()
|
||||
<< "' Time since last ping: " << now - last_ping << "s\n";
|
||||
// Reset last_ping if we didn't check for the last 10s.
|
||||
if (last_ping_check + 10 <= now) last_ping = now;
|
||||
if (static_cast<time_t>(last_ping + network::ping_timeout) <= now) {
|
||||
if (static_cast<time_t>(last_ping + network::ping_interval + network::ping_timeout) <= now) {
|
||||
|
||||
time_t timeout = now - last_ping;
|
||||
ERR_NW << "No server ping since " << timeout
|
||||
|
@ -258,6 +258,8 @@ statistics get_receive_stats(connection handle);
|
||||
|
||||
/** Amount of seconds after the last server ping when we assume to have timed out. */
|
||||
extern unsigned int ping_timeout;
|
||||
/** Minimum interval between pings. */
|
||||
const int ping_interval = 30;
|
||||
} // network namespace
|
||||
|
||||
|
||||
|
@ -604,7 +604,7 @@ void server::run() {
|
||||
}
|
||||
|
||||
time_t now = time(NULL);
|
||||
if (last_ping_ + 30 <= now) {
|
||||
if (last_ping_ + network::ping_interval <= now) {
|
||||
if (lan_server_ && players_.empty() && last_user_seen_time_ + lan_server_ < now)
|
||||
{
|
||||
LOG_SERVER << "Lan server has been empty for " << (now - last_user_seen_time_) << " seconds. Shutting down!\n";
|
||||
|
Loading…
x
Reference in New Issue
Block a user