mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-22 00:00:11 +02:00
runtime: fix leak in UnownedTask
This commit is contained in:
@@ -369,10 +369,16 @@ impl<S: Schedule> UnownedTask<S> {
|
||||
let raw = self.raw;
|
||||
mem::forget(self);
|
||||
|
||||
// Poll the task
|
||||
// Transfer one ref-count to a Task object.
|
||||
let task = Task::<S> {
|
||||
raw,
|
||||
_p: PhantomData,
|
||||
};
|
||||
|
||||
// Use the other ref-count to poll the task.
|
||||
raw.poll();
|
||||
// Decrement our extra ref-count
|
||||
raw.header().state.ref_dec();
|
||||
drop(task);
|
||||
}
|
||||
|
||||
pub(crate) fn shutdown(self) {
|
||||
|
||||
@@ -111,6 +111,12 @@ fn create_shutdown2() {
|
||||
drop(join);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn unowned_poll() {
|
||||
let (task, _) = unowned(async {}, NoopSchedule);
|
||||
task.run();
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn schedule() {
|
||||
with(|rt| {
|
||||
|
||||
Reference in New Issue
Block a user