Skip to content

Commit

Permalink
Fix deadlock and only push to contq if it's not a coding blob
Browse files Browse the repository at this point in the history
  • Loading branch information
sakridge committed Jun 2, 2018
1 parent 8ac9293 commit 45d7e58
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/streamer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ fn recv_window(
//if we get different blocks at the same index
//that is a network failure/attack
trace!("window w: {} size: {}", w, p.meta.size);
drop(p);
{
let mut window = locked_window.write().unwrap();
if window[w].is_none() {
Expand All @@ -290,12 +291,15 @@ fn recv_window(
if window[k].is_none() {
break;
}
let w_l1 = window[k].clone().unwrap();
let w_l2 = w_l1.read().unwrap();
if (w_l2.get_flags().unwrap() & BLOB_FLAG_IS_CODING) != 0 {
break;
let mut is_coding = false;
if let &Some(ref cblob) = &window[k] {
if (cblob.read().expect("blob read lock for flags streamer::window").get_flags().unwrap() & BLOB_FLAG_IS_CODING) != 0 {
is_coding = true;
}
}
if !is_coding {
contq.push_back(window[k].clone().expect("clone in fn recv_window"));
}
contq.push_back(window[k].clone().expect("clone in fn recv_window"));
window[k] = None;
*consumed += 1;
}
Expand Down

0 comments on commit 45d7e58

Please sign in to comment.