Skip to content

Commit

Permalink
fix race between block initialization and receiver disconnection
Browse files Browse the repository at this point in the history
  • Loading branch information
ibraheemdev authored Feb 26, 2024
1 parent b79db43 commit 580b003
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions library/std/src/sync/mpmc/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ impl<T> Channel<T> {
}

let mut head = self.head.index.load(Ordering::Acquire);
let mut block = self.head.block.load(Ordering::Acquire);
let mut block = self.head.block.swap(ptr::null_mut(), Ordering::AcqRel);

// If we're going to be dropping messages we need to synchronize with initialization
if head >> SHIFT != tail >> SHIFT {
Expand Down Expand Up @@ -588,8 +588,8 @@ impl<T> Channel<T> {
drop(Box::from_raw(block));
}
}

head &= !MARK_BIT;
self.head.block.store(ptr::null_mut(), Ordering::Release);
self.head.index.store(head, Ordering::Release);
}

Expand Down

0 comments on commit 580b003

Please sign in to comment.