Fix inverted logic

Revert part of 705bc0e4bb, which managed to
refactor code without improving it in any way AND introduce an inverted
logic bug.

This causes us to spam panic keepalives when we are timing out much
faster than intended.

Also, when deciding if it is time to take action, use inclusive comparisons.
If we ask to wake up at a certain time, and we do actually manage to wake up
at that exact time, then we should take action.  This is probably extremely
rare, however in an environment with limited timer precision, it could be
more common.
This commit is contained in:
Fletcher Dunn
2020-05-30 13:40:39 -07:00
parent 000ed53e18
commit 8f60b0e6bf
@@ -579,9 +579,10 @@ struct LinkStatsTrackerBase
/// connectivity as well.
inline bool BNeedToSendPingImmediate( SteamNetworkingMicroseconds usecNow ) const
{
if ( m_bPassive || m_nReplyTimeoutsSinceLastRecv == 0 )
return false;
return usecNow < m_usecLastSendPacketExpectingImmediateReply+k_usecAggressivePingInterval;
return
!m_bPassive
&& m_nReplyTimeoutsSinceLastRecv > 0 // We're timing out
&& m_usecLastSendPacketExpectingImmediateReply+k_usecAggressivePingInterval <= usecNow; // we haven't just recently sent an aggressive ping.
}
/// Check if we should send a keepalive ping. In this case we haven't heard from the peer in a while,
@@ -591,7 +592,7 @@ struct LinkStatsTrackerBase
return
!m_bPassive
&& m_usecInFlightReplyTimeout == 0 // not already tracking some other message for which we expect a reply (and which would confirm that the connection is alive)
&& m_usecTimeLastRecv + k_usecKeepAliveInterval < usecNow; // haven't heard from the peer recently
&& m_usecTimeLastRecv + k_usecKeepAliveInterval <= usecNow; // haven't heard from the peer recently
}
/// Fill out message with everything we'd like to send. We don't assume that we will