Spew more if we don't send immediately.

Also added a comment about reusing m_usecTimeReceived, because this looks like a bug

P4:6407666
This commit is contained in:
Fletcher Dunn
2021-03-09 16:50:38 -08:00
parent d9aa4c6926
commit ca0356ff2a
2 changed files with 21 additions and 5 deletions
@@ -338,7 +338,7 @@ int64 CSteamNetworkConnectionBase::SNP_SendMessage( CSteamNetworkingMessage *pSe
// or at the Nagle time, if Nagle is active.)
//
// NOTE: Right now we might not actually be capable of sending end to end data.
// But that case is relatievly rare, and nothing will break if we try to right now.
// But that case is relatively rare, and nothing will break if we try to right now.
// On the other hand, just asking the question involved a virtual function call,
// and it will return success most of the time, so let's not make the check here.
if ( GetState() == k_ESteamNetworkingConnectionState_Connected )
@@ -349,14 +349,29 @@ int64 CSteamNetworkConnectionBase::SNP_SendMessage( CSteamNetworkingMessage *pSe
if ( usecNextThink > usecNow )
{
// We are rate limiting. Spew about it?
if ( m_senderState.m_messagesQueued.m_pFirst->SNPSend_UsecNagle() == 0 )
// Not ready to send yet. Is it because Nagle, or because we have previous
// data queued and are rate limited?
if ( usecNextThink > m_senderState.m_messagesQueued.m_pFirst->SNPSend_UsecNagle() )
{
SpewVerbose( "[%s] RATELIM QueueTime is %.1fms, SendRate=%.1fk, BytesQueued=%d\n",
// It's because of the rate limit
SpewVerbose( "[%s] Send RATELIM. QueueTime is %.1fms, SendRate=%.1fk, BytesQueued=%d, ping=%dms\n",
GetDescription(),
m_senderState.CalcTimeUntilNextSend() * 1e-3,
m_senderState.m_n_x * ( 1.0/1024.0),
m_senderState.PendingBytesTotal()
m_senderState.PendingBytesTotal(),
m_statsEndToEnd.m_ping.m_nSmoothedPing
);
}
else
{
// Waiting on nagle
SpewVerbose( "[%s] Send Nagle %.1fms. QueueTime is %.1fms, SendRate=%.1fk, BytesQueued=%d, ping=%dms\n",
GetDescription(),
( m_senderState.m_messagesQueued.m_pFirst->SNPSend_UsecNagle() - usecNow ) * 1e-3,
m_senderState.CalcTimeUntilNextSend() * 1e-3,
m_senderState.m_n_x * ( 1.0/1024.0),
m_senderState.PendingBytesTotal(),
m_statsEndToEnd.m_ping.m_nSmoothedPing
);
}
@@ -86,6 +86,7 @@ public:
/// Nagle timer to expire and send now (but this should behave the same as if the
/// timer < usecNow). If the timer is cleared, then all messages with lower message numbers
/// are also cleared.
// NOTE: Intentionally reusing the m_usecTimeReceived field, which is not used on outbound messages
inline SteamNetworkingMicroseconds SNPSend_UsecNagle() const { return m_usecTimeReceived; }
inline void SNPSend_SetUsecNagle( SteamNetworkingMicroseconds x ) { m_usecTimeReceived = x; }