From 096afea6f13692fddbfad0b07e5377cb2e81dd58 Mon Sep 17 00:00:00 2001 From: Mica White Date: Thu, 26 Dec 2024 11:06:23 -0500 Subject: Rename kill to poison --- src/collection/boxed.rs | 6 ++++-- src/collection/owned.rs | 4 ++-- src/collection/ref.rs | 4 ++-- src/collection/retry.rs | 4 ++-- src/collection/utils.rs | 4 ++-- 5 files changed, 12 insertions(+), 10 deletions(-) (limited to 'src/collection') diff --git a/src/collection/boxed.rs b/src/collection/boxed.rs index 2397bd3..a048d2b 100644 --- a/src/collection/boxed.rs +++ b/src/collection/boxed.rs @@ -21,9 +21,9 @@ fn contains_duplicates(l: &[&dyn RawLock]) -> bool { } unsafe impl RawLock for BoxedLockCollection { - fn kill(&self) { + fn poison(&self) { for lock in &self.locks { - lock.kill(); + lock.poison(); } } @@ -196,6 +196,8 @@ impl BoxedLockCollection { self.locks.clear(); // safety: this was allocated using a box, and is now unique let boxed: Box> = Box::from_raw(self.data.cast_mut()); + // to prevent a double free + std::mem::forget(self); boxed.into_inner() } diff --git a/src/collection/owned.rs b/src/collection/owned.rs index e4cfe46..59e1ff8 100644 --- a/src/collection/owned.rs +++ b/src/collection/owned.rs @@ -14,10 +14,10 @@ fn get_locks(data: &L) -> Vec<&dyn RawLock> { } unsafe impl RawLock for OwnedLockCollection { - fn kill(&self) { + fn poison(&self) { let locks = get_locks(&self.data); for lock in locks { - lock.kill(); + lock.poison(); } } diff --git a/src/collection/ref.rs b/src/collection/ref.rs index 4fa5485..a9c3579 100644 --- a/src/collection/ref.rs +++ b/src/collection/ref.rs @@ -40,9 +40,9 @@ where } unsafe impl RawLock for RefLockCollection<'_, L> { - fn kill(&self) { + fn poison(&self) { for lock in &self.locks { - lock.kill(); + lock.poison(); } } diff --git a/src/collection/retry.rs b/src/collection/retry.rs index 687c5ec..cb6a1fb 100644 --- a/src/collection/retry.rs +++ b/src/collection/retry.rs @@ -36,10 +36,10 @@ fn contains_duplicates(data: L) -> bool { } unsafe impl RawLock for RetryingLockCollection { - fn kill(&self) { + fn poison(&self) { let locks = get_locks(&self.data); for lock in locks { - lock.kill(); + lock.poison(); } } diff --git a/src/collection/utils.rs b/src/collection/utils.rs index f418386..36b19be 100644 --- a/src/collection/utils.rs +++ b/src/collection/utils.rs @@ -96,7 +96,7 @@ pub unsafe fn attempt_to_recover_locks_from_panic(locked: &RefCell