From 5800cb7965353d1ba3a64fb3bb9559487c1377d3 Mon Sep 17 00:00:00 2001 From: Keith Winstein Date: Sat, 4 Feb 2012 02:25:10 -0500 Subject: [PATCH] Choose server-side echo ack more carefully --- transportsender.cpp | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/transportsender.cpp b/transportsender.cpp index 02c9109..bb2b742 100644 --- a/transportsender.cpp +++ b/transportsender.cpp @@ -287,10 +287,15 @@ void TransportSender::set_ack_num( uint64_t s_ack_num ) template uint64_t TransportSender::get_late_ack( uint64_t now ) { - ack_history.remove_if( [&]( const pair &x ) { return x.second < now - ECHO_TIMEOUT; } ); - if ( !ack_history.empty() ) { - return ack_history.front().first - 1; - } else { /* every ack has gone past the echo timeout */ - return ack_num; + uint64_t newest_echo_ack = 0; + + for ( auto i = ack_history.begin(); i != ack_history.end(); i++ ) { + if ( i->second < now - ECHO_TIMEOUT ) { + newest_echo_ack = i->first; + } } + + ack_history.remove_if( [&]( const pair &x ) { return x.first < newest_echo_ack; } ); + + return newest_echo_ack; }