Merge 'tokio-1.52.4' into 'master' (#8290)

This commit is contained in:
Alice Ryhl
2026-07-16 13:27:30 +00:00
6 changed files with 82 additions and 5 deletions
+1 -1
View File
@@ -60,7 +60,7 @@ Make sure you enable the full features of the tokio crate on Cargo.toml:
```toml
[dependencies]
tokio = { version = "1.52.3", features = ["full"] }
tokio = { version = "1.52.4", features = ["full"] }
```
Then, on your main.rs:
+20
View File
@@ -1,3 +1,15 @@
# 1.52.4 (July 16th, 2026)
### Fixed
- runtime: don't skip the driver when `before_park` schedules work ([#8222])
### Fixed (unstable)
- taskdump: remove crate disambiguators from output ([#8264])
[#8264]: https://github.com/tokio-rs/tokio/pull/8264
# 1.52.3 (May 8th, 2026)
### Fixed
@@ -64,6 +76,14 @@ This release reverts the LIFO slot stealing change introduced in 1.51.0
[#8035]: https://github.com/tokio-rs/tokio/pull/8035
[#8040]: https://github.com/tokio-rs/tokio/pull/8040
# 1.51.4 (July 16th, 2026)
### Fixed
- runtime: don't skip the driver when `before_park` schedules work ([#8222])
[#8222]: https://github.com/tokio-rs/tokio/pull/8222
# 1.51.3 (May 8th, 2026)
### Fixed
+1 -1
View File
@@ -6,7 +6,7 @@ name = "tokio"
# - README.md
# - Update CHANGELOG.md.
# - Create "v1.x.y" git tag.
version = "1.52.3"
version = "1.52.4"
edition = "2021"
rust-version = "1.71"
authors = ["Tokio Contributors <[email protected]>"]
+1 -1
View File
@@ -60,7 +60,7 @@ Make sure you enable the full features of the tokio crate on Cargo.toml:
```toml
[dependencies]
tokio = { version = "1.52.3", features = ["full"] }
tokio = { version = "1.52.4", features = ["full"] }
```
Then, on your main.rs:
@@ -415,8 +415,6 @@ impl Context {
core = c;
}
// If `before_park` spawns a task (or otherwise schedules work for us), then we should not
// park the thread.
if !self.has_pending_work(&core) {
// Park until the thread is signaled
core.metrics.about_to_park();
@@ -426,6 +424,15 @@ impl Context {
core.metrics.unparked();
core.submit_metrics(handle);
} else {
// `before_park` scheduled work (e.g. an `on_thread_park` hook that woke the
// `block_on` future), so we don't block. We must still poll the driver once
// without blocking, or timer and I/O events would stall under a runtime driven
// by repeated short `block_on` calls. See
// <https://github.com/tokio-rs/tokio/issues/8212>.
core.submit_metrics(handle);
core = self.park_internal(core, handle, &mut driver, Some(Duration::from_millis(0)));
}
if let Some(f) = &handle.shared.config.after_unpark {
+50
View File
@@ -4,6 +4,7 @@
use std::sync::atomic::{AtomicBool, Ordering};
use std::sync::Arc;
use std::time::Duration;
use tokio::runtime::Builder;
use tokio::sync::Notify;
@@ -90,3 +91,52 @@ fn wake_from_other_thread_block_on() {
th.join().unwrap();
}
// Regression test for #8212: a current-thread runtime driven by repeated short
// `block_on` calls, where `on_thread_park` wakes the `block_on` future, must
// still drive the time driver so a spawned timer keeps making progress. Before
// the fix, `before_park` setting the `woken` flag caused `park` to skip the
// driver entirely, so the timer never fired.
#[test]
fn before_park_does_not_stall_spawned_timer() {
let notify = Arc::new(Notify::new());
let task_done = Arc::new(AtomicBool::new(false));
let rt = Builder::new_current_thread()
.enable_all()
.on_thread_park({
let notify = notify.clone();
move || notify.notify_waiters()
})
.build()
.unwrap();
rt.spawn({
let task_done = task_done.clone();
async move {
tokio::time::sleep(Duration::from_millis(1)).await;
task_done.store(true, Ordering::SeqCst);
}
});
// A current-thread runtime only runs tasks while inside `block_on`, so drive it
// once to let the spawned task register its timer.
rt.block_on(tokio::task::yield_now());
// Drive the runtime in short bursts, the way an external event loop would. Each
// burst parks via `on_thread_park` (which wakes the `block_on` future); the fix
// keeps polling the driver so the spawned timer still fires. A regression stalls
// the timer, failing the assert below instead of hanging.
for _ in 0..100 {
if task_done.load(Ordering::SeqCst) {
break;
}
rt.block_on(notify.notified());
std::thread::sleep(Duration::from_millis(1));
}
assert!(
task_done.load(Ordering::SeqCst),
"spawned task's timer never fired (issue #8212)"
);
}