remove panic from Debug of StreamRef is mutex is poisoned

This commit is contained in:
Sean McArthur
2017-10-06 12:26:23 -07:00
parent 7b81be04aa
commit bc679035f9

View File

@@ -734,12 +734,20 @@ where
P: Peer, P: Peer,
{ {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
let me = self.inner.lock().unwrap(); match self.inner.lock() {
let stream = &me.store[self.key]; Ok(me) => {
fmt.debug_struct("StreamRef") let stream = &me.store[self.key];
.field("stream_id", &stream.id) fmt.debug_struct("StreamRef")
.field("ref_count", &stream.ref_count) .field("stream_id", &stream.id)
.finish() .field("ref_count", &stream.ref_count)
.finish()
},
Err(_poisoned) => {
fmt.debug_struct("StreamRef")
.field("inner", &"<Poisoned>")
.finish()
}
}
} }
} }