net: Fix is_alive returning false by giving some leniency

This commit is contained in:
Joshua Scott 2018-04-24 20:06:53 +01:00
parent 9c6a756f68
commit 05e48a2cbb
2 changed files with 4 additions and 4 deletions

View File

@ -42,12 +42,12 @@ namespace net
if (!m_established) if (!m_established)
return std::chrono::duration_cast<std::chrono::seconds>( return std::chrono::duration_cast<std::chrono::seconds>(
std::chrono::steady_clock::now() - m_creation_time std::chrono::steady_clock::now() - m_creation_time
).count() <= KI_CONNECTION_TIMEOUT; ).count() <= (KI_CONNECTION_TIMEOUT * 2);
// Otherwise, use the last time we received a heartbeat. // Otherwise, use the last time we received a heartbeat.
return std::chrono::duration_cast<std::chrono::seconds>( return std::chrono::duration_cast<std::chrono::seconds>(
std::chrono::steady_clock::now() - m_last_received_heartbeat_time std::chrono::steady_clock::now() - m_last_received_heartbeat_time
).count() <= KI_SERVER_HEARTBEAT; ).count() <= (KI_SERVER_HEARTBEAT * 2);
} }
void ClientSession::on_connected() void ClientSession::on_connected()

View File

@ -34,12 +34,12 @@ namespace net
if (!m_established) if (!m_established)
return std::chrono::duration_cast<std::chrono::seconds>( return std::chrono::duration_cast<std::chrono::seconds>(
std::chrono::steady_clock::now() - m_creation_time std::chrono::steady_clock::now() - m_creation_time
).count() <= KI_CONNECTION_TIMEOUT; ).count() <= (KI_CONNECTION_TIMEOUT * 2);
// Otherwise, use the last time we received a heartbeat. // Otherwise, use the last time we received a heartbeat.
return std::chrono::duration_cast<std::chrono::seconds>( return std::chrono::duration_cast<std::chrono::seconds>(
std::chrono::steady_clock::now() - m_last_received_heartbeat_time std::chrono::steady_clock::now() - m_last_received_heartbeat_time
).count() <= KI_CLIENT_HEARTBEAT; ).count() <= (KI_CLIENT_HEARTBEAT * 2);
} }
void ServerSession::on_connected() void ServerSession::on_connected()