fix race between block initialization and receiver disconnection
This commit is contained in:
parent
b79db437dc
commit
580b003edd
1 changed files with 2 additions and 2 deletions
|
@ -547,7 +547,7 @@ impl<T> Channel<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut head = self.head.index.load(Ordering::Acquire);
|
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 we're going to be dropping messages we need to synchronize with initialization
|
||||||
if head >> SHIFT != tail >> SHIFT {
|
if head >> SHIFT != tail >> SHIFT {
|
||||||
|
@ -588,8 +588,8 @@ impl<T> Channel<T> {
|
||||||
drop(Box::from_raw(block));
|
drop(Box::from_raw(block));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
head &= !MARK_BIT;
|
head &= !MARK_BIT;
|
||||||
self.head.block.store(ptr::null_mut(), Ordering::Release);
|
|
||||||
self.head.index.store(head, Ordering::Release);
|
self.head.index.store(head, Ordering::Release);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue