Add the minimum ping interval to the ping timeout.

Define this interval as a constant in network.hpp
This commit is contained in:
Alexander van Gessel 2010-04-12 03:44:53 +01:00
parent 35df198854
commit 8f2f43d3ea
4 changed files with 5 additions and 3 deletions

View File

@ -71,7 +71,7 @@
default=0
min=0
max=60
step=1
step=5
[/advanced_preference]
[advanced_preference]

View File

@ -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

View File

@ -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

View File

@ -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";