mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-09-08 00:00:13 +02:00
sync: free chan Blocks when Chan is dropped (#978)
This commit is contained in:
committed by
Carl Lerche
parent
a1871b1480
commit
27148d6110
@@ -326,10 +326,13 @@ impl<T, S> Drop for Chan<T, S> {
|
||||
fn drop(&mut self) {
|
||||
use super::block::Read::Value;
|
||||
|
||||
// Safety: the only owner of the rx fields is Chan, and eing
|
||||
// inside its own Drop means we're the last ones to touch it.
|
||||
self.rx_fields.with_mut(|rx_fields_ptr| {
|
||||
let rx_fields = unsafe { &mut *rx_fields_ptr };
|
||||
|
||||
while let Some(Value(_)) = rx_fields.list.pop(&self.tx) {}
|
||||
unsafe { rx_fields.list.free_blocks() };
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user