diff options
| author | Ibraheem Ahmed <ibraheem@ibraheem.ca> | 2024-02-26 13:53:35 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-26 13:53:35 -0500 |
| commit | 580b003edd9653201583df2944875a3605739f96 (patch) | |
| tree | 2cf6ff49ad15c1815f3c785ea40bcb1bf82de595 | |
| parent | b79db437dccd496948bb1819d36ed51598563a98 (diff) | |
| download | rust-580b003edd9653201583df2944875a3605739f96.tar.gz rust-580b003edd9653201583df2944875a3605739f96.zip | |
fix race between block initialization and receiver disconnection
| -rw-r--r-- | library/std/src/sync/mpmc/list.rs | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/library/std/src/sync/mpmc/list.rs b/library/std/src/sync/mpmc/list.rs index 406a331a309..a1b275112a1 100644 --- a/library/std/src/sync/mpmc/list.rs +++ b/library/std/src/sync/mpmc/list.rs @@ -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 { @@ -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); } |
