diff options
author | Zahari Dichev <zaharidichev@gmail.com> | 2020-09-25 18:38:13 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-09-25 08:38:13 -0700 |
commit | 444660664b96f758610a0e7201a6a1a31a0f2405 (patch) | |
tree | 0b6829c695a5a0e2cec1157f84ecbe10a0780a3c /tokio/src/io/util | |
parent | cf025ba45f68934ae2138bb75ee2a5ee50506d1b (diff) |
chore: handle std `Mutex` poisoning in a shim (#2872)
As tokio does not rely on poisoning, we can
avoid always unwrapping when locking by handling
the `PoisonError` in the Mutex shim.
Signed-off-by: Zahari Dichev <zaharidichev@gmail.com>
Diffstat (limited to 'tokio/src/io/util')
-rw-r--r-- | tokio/src/io/util/mem.rs | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/tokio/src/io/util/mem.rs b/tokio/src/io/util/mem.rs index 1b9b37b7..0dd6ad77 100644 --- a/tokio/src/io/util/mem.rs +++ b/tokio/src/io/util/mem.rs @@ -100,7 +100,7 @@ impl AsyncRead for DuplexStream { cx: &mut task::Context<'_>, buf: &mut ReadBuf<'_>, ) -> Poll<std::io::Result<()>> { - Pin::new(&mut *self.read.lock().unwrap()).poll_read(cx, buf) + Pin::new(&mut *self.read.lock()).poll_read(cx, buf) } } @@ -111,7 +111,7 @@ impl AsyncWrite for DuplexStream { cx: &mut task::Context<'_>, buf: &[u8], ) -> Poll<std::io::Result<usize>> { - Pin::new(&mut *self.write.lock().unwrap()).poll_write(cx, buf) + Pin::new(&mut *self.write.lock()).poll_write(cx, buf) } #[allow(unused_mut)] @@ -119,7 +119,7 @@ impl AsyncWrite for DuplexStream { mut self: Pin<&mut Self>, cx: &mut task::Context<'_>, ) -> Poll<std::io::Result<()>> { - Pin::new(&mut *self.write.lock().unwrap()).poll_flush(cx) + Pin::new(&mut *self.write.lock()).poll_flush(cx) } #[allow(unused_mut)] @@ -127,14 +127,14 @@ impl AsyncWrite for DuplexStream { mut self: Pin<&mut Self>, cx: &mut task::Context<'_>, ) -> Poll<std::io::Result<()>> { - Pin::new(&mut *self.write.lock().unwrap()).poll_shutdown(cx) + Pin::new(&mut *self.write.lock()).poll_shutdown(cx) } } impl Drop for DuplexStream { fn drop(&mut self) { // notify the other side of the closure - self.write.lock().unwrap().close(); + self.write.lock().close(); } } |