diff options
| -rw-r--r-- | rtic-sync/src/channel.rs | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/rtic-sync/src/channel.rs b/rtic-sync/src/channel.rs index d3a64b6..0aeb4a4 100644 --- a/rtic-sync/src/channel.rs +++ b/rtic-sync/src/channel.rs @@ -366,11 +366,16 @@ impl<T, const N: usize> Sender<'_, T, N> { let link = unsafe { link_ptr.get() }; // We are already in the wait queue. - if let Some(link) = link { - if link.is_popped() { + if let Some(queue_link) = link { + if queue_link.is_popped() { // SAFETY: `free_slot_ptr` is valid for writes until the end of this future. let slot = unsafe { free_slot_ptr.replace(None, cs) }; + // Our link was popped, so it is most definitely not in the list. + // We can safely & correctly `take` it to prevent ourselves from + // redundantly attempting to remove it from the list a 2nd time. + link.take(); + // If our link is popped, then: // 1. We were popped by `return_free_lot` and provided us with a slot. // 2. We were popped by `Receiver::drop` and it did not provide us with a slot, and the channel is closed. |
