From f96fa96ce28e3d4f2c31242a4ea50d37a349c52b Mon Sep 17 00:00:00 2001 From: Braulio Valdivielso Date: Mon, 24 Jan 2022 22:22:23 +0000 Subject: [PATCH] fixup! spawn_mandatory_blocking: fix race with shutdown --- tokio/src/runtime/tests/loom_blocking.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tokio/src/runtime/tests/loom_blocking.rs b/tokio/src/runtime/tests/loom_blocking.rs index 51f1519ed72..89de85e4362 100644 --- a/tokio/src/runtime/tests/loom_blocking.rs +++ b/tokio/src/runtime/tests/loom_blocking.rs @@ -49,7 +49,7 @@ fn spawn_mandatory_blocking_should_run_even_when_shutting_down_from_other_thread use crate::runtime::tests::loom_oneshot; loom::model(|| { let rt = runtime::Builder::new_current_thread().build().unwrap(); - let _enter = rt.enter(); + let handle = rt.handle().clone(); // Drop the runtime in a different thread { @@ -58,6 +58,7 @@ fn spawn_mandatory_blocking_should_run_even_when_shutting_down_from_other_thread }); } + let _enter = handle.enter(); let (tx, rx) = loom_oneshot::channel(); let handle = runtime::spawn_mandatory_blocking(move || { let _ = tx.send(());