From 21e2279209cf184f89e183ddf63301f980dd3a3f Mon Sep 17 00:00:00 2001 From: lifegpc Date: Tue, 21 Jun 2022 00:44:34 +0000 Subject: [PATCH] panic if RwLock is poisoned --- src/ext/rw_lock.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/ext/rw_lock.rs b/src/ext/rw_lock.rs index 63a974f..f14bbfb 100644 --- a/src/ext/rw_lock.rs +++ b/src/ext/rw_lock.rs @@ -14,6 +14,9 @@ impl GetRwLock for RwLock { type Target = T; fn get_ref<'a>(&'a self) -> RwLockReadGuard<'a, Self::Target> { loop { + if self.is_poisoned() { + panic!("Target is poisoned."); + } match self.try_read() { Ok(f) => { return f; @@ -26,6 +29,9 @@ impl GetRwLock for RwLock { } fn get_mut<'a>(&'a self) -> RwLockWriteGuard<'a, Self::Target> { loop { + if self.is_poisoned() { + panic!("Target is poisoned."); + } match self.try_write() { Ok(f) => { return f;