fix race between block initialization and receiver disconnection
This commit is contained in:
parent
b79db437dc
commit
580b003edd
@ -547,7 +547,7 @@ fn discard_all_messages(&self) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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 @@ fn discard_all_messages(&self) {
|
|||||||
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…
Reference in New Issue
Block a user