This commit is contained in:
Rob Walker
2018-07-18 22:10:01 -07:00
parent a58c83d999
commit ddb24ebb61
2 changed files with 15 additions and 4 deletions

View File

@ -167,8 +167,9 @@ pub fn decode_blocks(
Ok(()) Ok(())
} }
// Generate coding blocks in window starting from consumed, // Generate coding blocks in window starting from start_idx,
// for each block place the coding blobs at the end of the block // for num_blobs.. For each block place the coding blobs
// at the end of the block like so:
// //
// block-size part of a Window, with each element a WindowSlot.. // block-size part of a Window, with each element a WindowSlot..
// |<======================= NUM_DATA ==============================>| // |<======================= NUM_DATA ==============================>|

View File

@ -328,7 +328,7 @@ fn process_blob(
// Search the window for old blobs in the window // Search the window for old blobs in the window
// of consumed to received and clear any old ones // of consumed to received and clear any old ones
for ix in *consumed..(pix + 1) { for ix in *consumed..(received + 1) {
let k = (ix % WINDOW_SIZE) as usize; let k = (ix % WINDOW_SIZE) as usize;
let mut old = false; let mut old = false;
@ -337,15 +337,16 @@ fn process_blob(
} }
if old { if old {
if let Some(b) = mem::replace(&mut window[k].data, None) { if let Some(b) = mem::replace(&mut window[k].data, None) {
debug!("{:x}: recycling data blob at index {:}", debug_id, k);
recycler.recycle(b); recycler.recycle(b);
} }
} }
let mut old = false;
if let Some(b) = &window[k].coding { if let Some(b) = &window[k].coding {
old = b.read().unwrap().get_index().unwrap() < *consumed; old = b.read().unwrap().get_index().unwrap() < *consumed;
} }
if old { if old {
if let Some(b) = mem::replace(&mut window[k].coding, None) { if let Some(b) = mem::replace(&mut window[k].coding, None) {
debug!("{:x}: recycling coding blob at index {:}", debug_id, k);
recycler.recycle(b); recycler.recycle(b);
} }
} }
@ -394,6 +395,15 @@ fn process_blob(
} }
} }
// // Search the window for wrong data blobs...
// for ix in *consumed..(received + 1) {
// let k = (ix % WINDOW_SIZE) as usize;
//
// if let Some(b) = &window[k].data {
// assert_eq!(ix, b.read().unwrap().get_index().unwrap());
// }
// }
// push all contiguous blobs into consumed queue, increment consumed // push all contiguous blobs into consumed queue, increment consumed
while *consumed < received { while *consumed < received {
let k = (*consumed % WINDOW_SIZE) as usize; let k = (*consumed % WINDOW_SIZE) as usize;