From 5dd2f737a373419286ad7ca398ae8dbd61d1a11e Mon Sep 17 00:00:00 2001 From: Rob Walker Date: Tue, 31 Jul 2018 15:45:03 -0700 Subject: [PATCH] clear out old blobs in find_next_missing --- src/streamer.rs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/streamer.rs b/src/streamer.rs index 495370727a..a6777ca0f1 100644 --- a/src/streamer.rs +++ b/src/streamer.rs @@ -179,10 +179,17 @@ fn find_next_missing( if received <= consumed { Err(WindowError::GenericError)?; } - let window = window.read().unwrap(); + let mut window = window.write().unwrap(); let reqs: Vec<_> = (consumed..received) .filter_map(|pix| { let i = (pix % WINDOW_SIZE) as usize; + + if let Some(blob) = mem::replace(&mut window[i].data, None) { + let blob_idx = blob.read().unwrap().get_index().unwrap(); + if blob_idx == pix { + mem::replace(&mut window[i].data, Some(blob)); + } + } if window[i].data.is_none() { let val = crdt.read().unwrap().window_index_request(pix as u64); if let Ok((to, req)) = val {