runtime: fix leak in UnownedTask

This commit is contained in:
Alice Ryhl
2021-08-24 17:48:25 +02:00
committed by Alice Ryhl
parent c0974bad94
commit 4152918a39
2 changed files with 14 additions and 2 deletions
+8 -2
View File
@@ -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) {
+6
View File
@@ -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| {