Skip to content

Commit

Permalink
[RSDK-9366] Clear poisoned lock in tests (#371)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattjperez authored Jan 7, 2025
1 parent a4d72d8 commit 3baca97
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion micro-rdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,11 @@ mod tests {
pub fn global_network_test_lock<'a>() -> MutexGuard<'a, ()> {
static LOCK: OnceLock<Mutex<()>> = OnceLock::new();
let lock = LOCK.get_or_init(|| Mutex::new(()));
lock.lock().unwrap()
lock.lock().unwrap_or_else(|lock_result| {
// the shared data is (), which is not modifiable
// therefore always in a consistent state
lock.clear_poison();
lock_result.into_inner()
})
}
}

0 comments on commit 3baca97

Please sign in to comment.