Skip to content

Commit fc3800f

Browse files
committed
Auto merge of #121646 - ibraheemdev:patch-17, r=ChrisDenton
Fix race between block initialization and receiver disconnection Port of crossbeam-rs/crossbeam#1084. Closes #121582.
2 parents 829308e + 580b003 commit fc3800f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

library/std/src/sync/mpmc/list.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,7 @@ impl<T> Channel<T> {
547547
}
548548

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

552552
// If we're going to be dropping messages we need to synchronize with initialization
553553
if head >> SHIFT != tail >> SHIFT {
@@ -588,8 +588,8 @@ impl<T> Channel<T> {
588588
drop(Box::from_raw(block));
589589
}
590590
}
591+
591592
head &= !MARK_BIT;
592-
self.head.block.store(ptr::null_mut(), Ordering::Release);
593593
self.head.index.store(head, Ordering::Release);
594594
}
595595

0 commit comments

Comments
 (0)