Commit Graph
4136 Commits
Author SHA1 Message Date
Eliza Weisman ab3ff69cf2 chore: prepare to release v1.46.1 (#7444)
# 1.46.1 (July 4th, 2025)

This release fixes incorrect spawn locations in runtime task hooks for tasks
spawned using `tokio::spawn` rather than `Runtime::spawn`. This issue only
effected the spawn location in `TaskMeta::spawned_at`, and did not effect task
locations in Tracing events.

## Unstable

- runtime: add `TaskMeta::spawn_location` tracking where a task was spawned
  ([#7440)])

[#7440]: https://github.com/tokio-rs/tokio/pull/7440
tokio-1.46.1
2025-07-04 19:27:35 +00:00
Eliza Weisman a0d5b8ab30 runtime(unstable): fix task hook spawn locations for tokio::spawn (#7440)
## Motivation

Unfortunately, due to an oversight on my part, the capturing of spawn
locations was only tested with the `Runtime::spawn` method, and *not*
with `tokio::spawn`/`tokio::task::spawn`, which is how most tasks are
spawned in Real Life. And, it turned out that because this was not
tested...well, it was broken. Agh. My bad.

## Solution

Although the whole call chain for spawning tasks using `tokio::spawn`
was correctly annotated with `#[track_caller]`, the location wasn't
propagated correctly because of the `context::with_current(|handle| {
... })` closure that accesses the current runtime. Because the call to
spawn the task occurs inside a closure, the *closure*'s location is
captured instead of the caller. This means any task spawned by
`tokio::spawn` records its location as being in
`tokio/src/task/spawn.rs`, which is not what we'd like. This commit
fixes that by capturing the spawn location outside the `with_current`
closure and passing it in explicitly.

I've updated the tests to also spawn a task with `tokio::spawn`, so that
we ensure this works correctly.
2025-07-04 09:25:40 -07:00
shangchenglumetro a1ee3ef218 chore: fix some minor typos in the comments (#7442)
Signed-off-by: shangchenglumetro <[email protected]>
2025-07-04 11:29:27 +02:00
Alice Ryhl 171cd148a3 changelog: fix typo in pipe::OpenOptions for 1.46.0 (#7439) 2025-07-02 09:27:11 +00:00
Eliza Weisman 3f1f268583 chore: prepare Tokio v1.46.0 (#7437) tokio-1.46.0 2025-07-02 10:20:42 +02:00
Eliza Weisman 3e890cc017 rt(unstable): add spawn Location to TaskMeta (#7417)
As described in issue #7411, task spawning APIs are currently annotated
with `#[track_caller]`, allowing us to capture the location in the user
source code where the task was spawned. This is used for `tracing`
events used by `tokio-console` and friends. However, this information is
*not* exposed to the runtime `on_task_spawn`, `on_before_task_poll`,
`on_after_task_poll`, and `on_task_terminate` hooks, which is a shame,
as it would be useful there as well.

This branch adds the task's spawn location to the `TaskMeta` struct
provided to the runtime's task hooks. This is implemented by storing a
`&'static Location<'static>` in the task's `Core` alongside the
`task::Id`. In [this comment][1], @ADD-SP suggested storing the
`Location` in the task's `Trailer`.

I opted to store it in the `Core` instead, as the `Trailer` is intended
to store "cold" data that is only accessed when the task _completes_,
and not on every poll. Since the task meta is passed to the
`on_before_task_poll` and `on_after_task_poll` hooks, we would be
accessing the `Trailer` on polls if we stored the `Location` there.
Therefore, I put it in the `Core`, instead, which contains data that we
access every time the task is polled.

Closes #7411

[1]: https://github.com/tokio-rs/tokio/issues/7411#issuecomment-2993377045
2025-06-30 18:13:42 +00:00
xumaple 69290a6432 net: derive Clone for net::unix::SocketAddr (#7422) 2025-06-30 15:31:04 +02:00
Alice Ryhl e2b175848b fuzz: cfg fuzz tests under cfg(test) (#7428) 2025-06-30 10:24:10 +02:00
GarmashAlex b7a75b5be3 net: update AsRawFd doc link to current Rust stdlib location (#7429) 2025-06-27 14:08:31 +00:00
Marshall Pierce 6b705b3053 net: allow pipe::OpenOptions::read_write on Android (#7426) 2025-06-27 09:39:55 +02:00
VolodymyrBg 3636fd018a net: fix broken link of RawFd in TcpSocket docs (#7416) 2025-06-24 21:15:39 +08:00
Alice Ryhl 2506c9fa99 benches: revert "properly gate unix benches" (#7412)
This reverts commit 933fa498d0.
2025-06-21 14:52:04 +02:00
QiandAlice Ryhl b3a14483bf sync: improve docs of tokio_util::sync::CancellationToken (#7408)
Co-authored-by: Alice Ryhl <[email protected]>
2025-06-19 06:32:41 +08:00
Qi 013f323def docs: add a missing panic scenario of time::advance (#7394) 2025-06-18 20:25:12 +08:00
yanyuxing b926700065 sync: add DropGuardRef for CancellationToken (#7407) 2025-06-18 10:25:41 +02:00
Alice Ryhl 99a03a502e runtime: add thread_park_ok test (#7402) 2025-06-16 09:49:00 +02:00
Tim Vilgot Mikael Fredenberg 933fa498d0 benches: properly gate unix benches (#7392) 2025-06-11 10:07:34 +02:00
Motoyuki Kimura 9f848c9f54 rt: add check for io_uring availability at runtime (#7357) 2025-06-11 03:26:23 +09:00
Geoffry Song 912b862a05 task: add AbortOnDropHandle::detach (#7400) 2025-06-10 09:35:48 +02:00
Qi 714e5b571f runtime: move impl Schedule for Arc<Handle> (#7398) 2025-06-09 09:32:59 +02:00
Jess Izen 8e999e3806 macros: add biased mode to join! and try_join! (#7307) 2025-06-09 09:31:05 +02:00
Oliver E. Anderson 1d980145cb io: document cancellation safety of AsyncWriteExt::flush (#7364) 2025-06-08 20:57:36 +02:00
Alice Ryhl 8259133ca0 task: disallow blocking in LocalSet::{poll,drop} (#7372) 2025-06-08 20:56:55 +02:00
Yuyi Wang 38d88c6799 net: add cygwin support (#7393) 2025-06-08 09:55:43 +02:00
Austin Bonander c38de96b94 sync: add same_channel analogue to OwnedPermit (#7389) 2025-06-07 13:10:48 +02:00
tiif 2440d113ff ci: enable tests using fcntl in miri (#7382) 2025-06-04 09:55:27 +02:00
Maximilian Hubert ab8d7b82a1 readme: fix double period in reactor description (#7363) 2025-05-28 21:24:53 +02:00
Qi 9563707aaa time: cumulative minor improvements (#7358) 2025-05-28 14:01:31 +02:00
Jeff Vander Stoep 193c1574a1 examples: update rand crate to 0.9.1 (#7371) 2025-05-28 11:32:24 +00:00
Alice Ryhl 328bd049f6 io: clarify behavior of seeking when start_seek is not used (#7366) 2025-05-28 13:00:33 +02:00
Tim Vilgot Mikael Fredenberg 4380de9fe9 chore: replace manual vtable definitions with Wake (#7342) 2025-05-28 02:28:21 +09:00
Alice Ryhl 98f527f42d Merge tag 'tokio-1.45.1' 2025-05-24 07:32:44 -07:00
Alice Ryhl 3768696d92 chore: prepare Tokio v1.45.1 (#7359) tokio-1.45.1 2025-05-24 14:27:50 +00:00
Alice Ryhl d7d4f7d08b sync: update broadcast docs on allocation failure (#7352) 2025-05-24 16:10:13 +02:00
Jason Gin 421a7b001c rt: do not track time-based metrics on wasm32-unknown-unknown (#7322) 2025-05-23 19:12:28 +00:00
Alice Ryhl b1bdb3c57b ci: update macros_type_mismatch for Rust 1.87.0 (#7339)
(cherry picked from commit a48e418dcb)
2025-05-23 10:39:10 -07:00
Qi 7ec77a0677 time: eliminate UnsafeCell around the TimerShared (#7329) 2025-05-23 19:24:29 +02:00
Qi 55e3ed2a39 runtime: eliminate unnecessary lfence while operating on queue::Local<T> (#7340) 2025-05-23 19:24:00 +02:00
Alice Ryhl 17d8c2b29d runtime: various minor LocalRuntime improvements (#7346) 2025-05-20 19:37:41 +02:00
Motoyuki Kimura 327bec2caf rt: add infrastructure code for io_uring (#7320) 2025-05-21 02:36:52 +09:00
Qi ea30a5ea5e time: rename cached_when to registered_when (#7333) 2025-05-20 14:55:28 +02:00
剑来 0cf95f0673 net: fix docs for recv_buffer_size method (#7336) 2025-05-17 09:51:31 +00:00
Alice Ryhl a48e418dcb ci: update macros_type_mismatch for Rust 1.87.0 (#7339) 2025-05-17 18:24:36 +09:00
Qi 4cbcb687f4 time: address style issues (#7328) 2025-05-12 23:32:23 +09:00
Qi 0715e6defc time: remove outdated explicitly drop call of Mutex (#7326)
This drop was firstly introduced by [#3289],
and the next line invokes `panic!`.

In [#5434], the original `panic!` was replaced
with `return Err`, so dropping it explicitly
is no longer necessary.

[#3289]: https://github.com/tokio-rs/tokio/pull/3289
[#5434]: https://github.com/tokio-rs/tokio/pull/5434
2025-05-12 22:18:43 +09:00
Alice Ryhl bdd64cc9d3 runtime: add doc note that on_*_task_poll is unstable (#7311) 2025-05-06 08:46:05 +00:00
soundofspace f0fdef80c4 net: ignore NotConnected in TcpStream::shutdown (#7290) 2025-05-06 17:27:40 +09:00
Carl Lerche 00754c8f9c chore: prepare Tokio v1.45.0 (#7308) tokio-1.45.0 2025-05-06 08:43:25 +02:00
Carl Lerche 1ae9434e8e time: revert "use sharding for timer implementation" related changes (#7226)
The work on sharding the timer implementation has caused a measurable performance regression due to increased contention. This patch reverts the current work on sharding. The next step will be to work on a per-worker timer wheel.
2025-05-05 10:48:02 -07:00
Taiki Endo 8895bba448 ci: Test AArch64 Windows (#7288) 2025-05-05 11:10:20 +02:00