From 61d553eccfbfa51bdc5fdf5913746bf557dff36a Mon Sep 17 00:00:00 2001 From: Fletcher Dunn Date: Thu, 28 May 2020 10:52:34 -0700 Subject: [PATCH] Fix bug in expiry of in-flight packets. This meant the map was growing without bound! The worse the packet loss, the worse the growth of this map. This didn't break the wire protocol, it was just bad for perf. But not that bad, because the data structure has a good O() time and all of the old packets that should have been expired were just not really examined. Until I added code to check it constantly. Then I noticed perf has tanked! I am actually surprised that static analysis didn't catch this. --- .../clientlib/steamnetworkingsockets_snp.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/steamnetworkingsockets/clientlib/steamnetworkingsockets_snp.cpp b/src/steamnetworkingsockets/clientlib/steamnetworkingsockets_snp.cpp index ad1ead1..db7f112 100644 --- a/src/steamnetworkingsockets/clientlib/steamnetworkingsockets_snp.cpp +++ b/src/steamnetworkingsockets/clientlib/steamnetworkingsockets_snp.cpp @@ -1206,10 +1206,9 @@ SteamNetworkingMicroseconds CSteamNetworkConnectionBase::SNP_SenderCheckInFlight ++inFlightPkt; // Expire old packets (all of these should have been marked as nacked) - SteamNetworkingMicroseconds usecNackExpiry = usecRTO*2; + SteamNetworkingMicroseconds usecWhenExpiry = usecNow - usecRTO*2; for (;;) { - SteamNetworkingMicroseconds usecWhenExpiry = inFlightPkt->second.m_usecWhenSent - usecNackExpiry; if ( inFlightPkt->second.m_usecWhenSent > usecWhenExpiry ) break;