summaryrefslogtreecommitdiffstats
path: root/tokio/src/runtime/park.rs
diff options
context:
space:
mode:
authorÉmile Grégoire <eg@emilegregoire.ca>2020-07-28 23:43:19 -0400
committerGitHub <noreply@github.com>2020-07-28 20:43:19 -0700
commit646fbae76535e397ef79dbcaacb945d4c829f666 (patch)
tree49c00b3825463cae83eef0e1b65ee3d8266980c3 /tokio/src/runtime/park.rs
parent1562bb314482215eb7517e6b8b8bdecbacf10e79 (diff)
rt: fix potential leak during runtime shutdown (#2649)
JoinHandle of threads created by the pool are now tracked and properly joined at shutdown. If the thread does not return within the timeout, then it's not joined and left to the OS for cleanup. Also, break a cycle between wakers held by the timer and the runtime. Fixes #2641, #2535
Diffstat (limited to 'tokio/src/runtime/park.rs')
-rw-r--r--tokio/src/runtime/park.rs12
1 files changed, 12 insertions, 0 deletions
diff --git a/tokio/src/runtime/park.rs b/tokio/src/runtime/park.rs
index ee437d1d..1dcf65af 100644
--- a/tokio/src/runtime/park.rs
+++ b/tokio/src/runtime/park.rs
@@ -104,6 +104,10 @@ impl Park for Parker {
Ok(())
}
}
+
+ fn shutdown(&mut self) {
+ self.inner.shutdown();
+ }
}
impl Unpark for Unparker {
@@ -242,4 +246,12 @@ impl Inner {
fn unpark_driver(&self) {
self.shared.handle.unpark();
}
+
+ fn shutdown(&self) {
+ if let Some(mut driver) = self.shared.driver.try_lock() {
+ driver.shutdown();
+ }
+
+ self.condvar.notify_all();
+ }
}