aboutsummaryrefslogtreecommitdiff
path: root/rtic-sync/src
diff options
context:
space:
mode:
authordatdenkikniet <jcdra1@gmail.com>2025-03-18 22:24:10 +0100
committerdatdenkikniet <38322042+datdenkikniet@users.noreply.github.com>2025-03-23 10:47:25 +0000
commitea56cc0ce8cfbe999872e371acfcc7fb86a0e839 (patch)
tree32602af8fc2f572c26bb87a15cc5c6eff8d12e9f /rtic-sync/src
parent11699b439126744ad918a1c6b90e73cb24da868d (diff)
rtic-sync: `take` link if it is popped
Diffstat (limited to 'rtic-sync/src')
-rw-r--r--rtic-sync/src/channel.rs9
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.