From 45d7e58db402f14265bbeba24d25b7271c57640b Mon Sep 17 00:00:00 2001 From: Stephen Akridge Date: Thu, 31 May 2018 15:48:29 -0700 Subject: [PATCH] Fix deadlock and only push to contq if it's not a coding blob --- src/streamer.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/streamer.rs b/src/streamer.rs index 0d41da65f79868..1c76d4cab6aa34 100644 --- a/src/streamer.rs +++ b/src/streamer.rs @@ -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() { @@ -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; }