Skip to content

Commit

Permalink
task: fix panic when dropping LocalSet
Browse files Browse the repository at this point in the history
it turns out that the `Scheduler::release` method on `LocalSet`'s
`Scheduler` *is* called, when the  `Scheduler` is dropped with tasks
still running. Currently, that method is `unreachable!`, which means
that dropping a `LocalSet` with tasks running will panic.

This commit fixes the panic, by pushing released tasks to
`pending_drop`. This is the same as `BasicScheduler`.

Fixes #1842

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
  • Loading branch information
hawkw committed Nov 27, 2019
1 parent 0637bc6 commit 5641a5e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions tokio/src/task/local.rs
Expand Up @@ -345,8 +345,9 @@ impl Schedule for Scheduler {
}
}

fn release(&self, _: Task<Self>) {
unreachable!("tasks should only be completed locally")
fn release(&self, task: Task<Self>) {
// This will be called when dropping the local runtime.
self.pending_drop.push(task);
}

fn release_local(&self, task: &Task<Self>) {
Expand Down

0 comments on commit 5641a5e

Please sign in to comment.