mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-28 00:00:11 +02:00
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
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
#![warn(rust_2018_idioms)]
|
||||
#![cfg(feature = "full")]
|
||||
|
||||
// Tests to run on both current-thread & therad-pool runtime variants.
|
||||
// Tests to run on both current-thread & thread-pool runtime variants.
|
||||
|
||||
macro_rules! rt_test {
|
||||
($($t:tt)*) => {
|
||||
@@ -869,6 +869,21 @@ rt_test! {
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn shutdown_wakeup_time() {
|
||||
let mut runtime = rt();
|
||||
|
||||
runtime.block_on(async move {
|
||||
tokio::time::delay_for(std::time::Duration::from_millis(100)).await;
|
||||
});
|
||||
|
||||
runtime.shutdown_timeout(Duration::from_secs(10_000));
|
||||
}
|
||||
|
||||
// This test is currently ignored on Windows because of a
|
||||
// rust-lang issue in thread local storage destructors.
|
||||
// See https://github.com/rust-lang/rust/issues/74875
|
||||
#[test]
|
||||
#[cfg(not(windows))]
|
||||
fn runtime_in_thread_local() {
|
||||
use std::cell::RefCell;
|
||||
use std::thread;
|
||||
|
||||
Reference in New Issue
Block a user