From bc679035f953acca6a5390756ffcc37354637ba2 Mon Sep 17 00:00:00 2001 From: Sean McArthur Date: Fri, 6 Oct 2017 12:26:23 -0700 Subject: [PATCH] remove panic from Debug of StreamRef is mutex is poisoned --- src/proto/streams/streams.rs | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/proto/streams/streams.rs b/src/proto/streams/streams.rs index 970e038..1030f6c 100644 --- a/src/proto/streams/streams.rs +++ b/src/proto/streams/streams.rs @@ -734,12 +734,20 @@ where P: Peer, { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { - let me = self.inner.lock().unwrap(); - let stream = &me.store[self.key]; - fmt.debug_struct("StreamRef") - .field("stream_id", &stream.id) - .field("ref_count", &stream.ref_count) - .finish() + match self.inner.lock() { + Ok(me) => { + let stream = &me.store[self.key]; + fmt.debug_struct("StreamRef") + .field("stream_id", &stream.id) + .field("ref_count", &stream.ref_count) + .finish() + }, + Err(_poisoned) => { + fmt.debug_struct("StreamRef") + .field("inner", &"") + .finish() + } + } } }