Call check_guard in decrement_with_pin
Make sure that the guard used belongs to the same instance as the one
used by the skip list.
@@ -230,7 +230,7 @@ impl<K, V> Node<K, V> {
/// Decrements the reference count of a node, pinning the thread and destoying the node
/// if the count become zero.
#[inline]
- unsafe fn decrement_with_pin<F>(&self, pin: F)
+ unsafe fn decrement_with_pin<F>(&self, parent: &SkipList<K, V>, pin: F)
where
F: FnOnce() -> Guard,
{
@@ -241,7 +241,9 @@ impl<K, V> Node<K, V> {
== 1
{
fence(Ordering::Acquire);
- pin().defer_unchecked(move || Self::finalize(self));
+ let guard = &pin();
+ parent.check_guard(guard);
+ guard.defer_unchecked(move || Self::finalize(self));
}
}
@@ -1431,7 +1433,7 @@ impl<'a, K: 'a, V: 'a> RefEntry<'a, K, V> {
where
F: FnOnce() -> Guard,
{
- unsafe { self.node.decrement_with_pin(pin) }
+ unsafe { self.node.decrement_with_pin(self.parent, pin) }
}
/// Tries to create a new `RefEntry` by incrementing the reference count of
