From 799b249f02282f360aad484340b8f02838222992 Mon Sep 17 00:00:00 2001 From: Stephen Akridge Date: Wed, 27 Jun 2018 10:13:51 -0700 Subject: [PATCH] Don't null blob window until we have to --- src/streamer.rs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/src/streamer.rs b/src/streamer.rs index 632cb8ffec..2f10de43f4 100644 --- a/src/streamer.rs +++ b/src/streamer.rs @@ -303,9 +303,22 @@ fn recv_window( debug!("duplicate blob at index {:}", w); } } + // recycle old references + for ix in *consumed..pix { + let k = (ix % WINDOW_SIZE) as usize; + if let Some(b) = &mut window[k] { + if b.read().unwrap().get_index().unwrap() >= *consumed as u64 { + continue; + } + } + if let Some(b) = mem::replace(&mut window[k], None) { + recycler.recycle(b); + } + } loop { let k = (*consumed % WINDOW_SIZE) as usize; trace!("k: {} consumed: {}", k, *consumed); + if window[k].is_none() { break; } @@ -322,11 +335,6 @@ fn recv_window( if !is_coding { contq.push_back(window[k].clone().expect("clone in fn recv_window")); *consumed += 1; - - #[cfg(not(feature = "erasure"))] - { - window[k] = None; - } } else { #[cfg(feature = "erasure")] {