From ce56278a68ce5a93d2768557b628ab9b9897a36f Mon Sep 17 00:00:00 2001 From: Milo Turner Date: Sat, 14 Mar 2020 15:03:55 -0400 Subject: [PATCH] send a lot of acks at the end --- hptp-recv/src/main.rs | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/hptp-recv/src/main.rs b/hptp-recv/src/main.rs index 826047c..819f809 100644 --- a/hptp-recv/src/main.rs +++ b/hptp-recv/src/main.rs @@ -131,7 +131,6 @@ where const DELAY_MS: u64 = 1000; let mut deadline = Instant::now(); - let mut to_send = vec![]; loop { let timer = tokio::time::delay_until(deadline); @@ -169,14 +168,10 @@ where } }; - { - let idxs = sink.ack_idxs(); + let num_acks = if sink.is_file_complete() { 8 } else { 1 }; + for _ in 0..num_acks { log.debug_msg(format!("send acks {:?}", idxs)).await; - to_send.push(DownMsg::Ack { idxs: idxs.clone() }); - to_send.push(DownMsg::Ack { idxs }); - } - - for m in to_send.drain(..) { + let m = DownMsg::Ack { idxs: sink.ack_idxs() }; match peer.send(m).await { Ok(()) => (), Err(hptp::peer::SendError::NoTarget) => log.debug_msg("no target").await,