Auto merge of #121646 - ibraheemdev:patch-17, r=ChrisDenton
Fix race between block initialization and receiver disconnection Port of https://github.com/crossbeam-rs/crossbeam/pull/1084. Closes https://github.com/rust-lang/rust/issues/121582.
This commit is contained in:
commit
fc3800f657
@ -547,7 +547,7 @@ fn discard_all_messages(&self) {
|
||||
}
|
||||
|
||||
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 @@ fn discard_all_messages(&self) {
|
||||
drop(Box::from_raw(block));
|
||||
}
|
||||
}
|
||||
|
||||
head &= !MARK_BIT;
|
||||
self.head.block.store(ptr::null_mut(), Ordering::Release);
|
||||
self.head.index.store(head, Ordering::Release);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user