We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents d3d145e + 7c9fa95 commit fe22159Copy full SHA for fe22159
library/std/src/sync/mpmc/list.rs
@@ -547,6 +547,9 @@ impl<T> Channel<T> {
547
}
548
549
let mut head = self.head.index.load(Ordering::Acquire);
550
+ // The channel may be uninitialized, so we have to swap to avoid overwriting any sender's attempts
551
+ // to initalize the first block before noticing that the receivers disconnected. Late allocations
552
+ // will be deallocated by the sender in Drop.
553
let mut block = self.head.block.swap(ptr::null_mut(), Ordering::AcqRel);
554
555
// If we're going to be dropping messages we need to synchronize with initialization
0 commit comments