2275 Commits

Author SHA1 Message Date
Sylwester Rąpała
5dcc848fc8
sync: add #[must_use] to Notified (#6828) 2024-09-06 09:03:27 +02:00
Timo
bd4ccae184
time: add abstraction for RwLock to remove poisoning aspect (#6807)
With #6779 we removed unnecessary allocations from the timerwheel by
wrapping it in an `std::sync::RwLock`. Since the `Mutex` used in this
part of the project uses an abstraction in `loom::sync::Mutex` to get
rid of the poisoning aspects of `std::sync::Mutex` the same should
probably be done for the used read-write lock struct.

This commit introduces an abstraction to get rid of the poisoning
aspects of `std::sync::RwLock` by introducing a wrapper to the
`loom::sync` module similar to `loom::sync::Mutex`.

Refs: #6779
2024-09-05 23:48:05 +09:00
Eduardo Sánchez Muñoz
12b2567b95
chore: use poll_fn from std (#6810) 2024-09-05 09:54:06 +02:00
Antonio de la Vega
27539ae3bd
runtime: fix race in yield_defers_until_park test (#6809) 2024-08-31 21:34:22 +02:00
Motoyuki Kimura
ea6d652a10
chore: prepare Tokio v1.40.0 (#6806) 2024-08-30 10:03:16 +02:00
Havish Maka
11f66f43a0
chore: replace ready! with std::task::ready! (#6804) 2024-08-29 22:02:56 +02:00
Timo
479a56a010
time: eliminate timer wheel allocations (#6779) 2024-08-27 22:18:29 +02:00
Noah Kennedy
b37f0de28a
runtime: implement initial set of task hooks (#6742) 2024-08-27 15:27:58 +02:00
Havish Maka
cc70a211ad
task: add join_all method to JoinSet (#6784)
Adds join_all method to JoinSet. join_all consumes JoinSet and awaits
the completion of all tasks on it, returning the results of the tasks in
a vec. An error or panic in the task will cause join_all to panic,
canceling all other tasks.

Fixes: #6664
2024-08-27 01:06:52 +09:00
Daniel Sedlak
ff3f2a8878
io: add SimplexStream (#6589) 2024-08-19 15:47:57 +02:00
rosscanning
5b9a290acd
io: clarify zero remaining capacity case (#6790) 2024-08-19 09:09:24 +09:00
Tobias Bucher
9bd6702a3f
sync: mark mpsc types as UnwindSafe (#6783) 2024-08-18 13:36:51 +02:00
mox692
365269adaf Merge 'tokio-1.39.x' into master (#6788) 2024-08-17 19:35:28 +09:00
Motoyuki Kimura
3d439ab711
chore: prepare Tokio v1.39.3 (#6782) 2024-08-17 10:26:43 +02:00
Motoyuki Kimura
b2ea40bb54
net: add handling for abstract socket name (#6772) 2024-08-16 23:50:34 +09:00
Rafael Bachmann
5ea3c63d7e
sync: document mpsc channel allocation behavior (#6773) 2024-08-16 12:31:03 +02:00
Eliza Weisman
56f3f40c15
tests: handle ECONNREFUSED in uds_stream::epollhup (#6778)
## Motivation

Currently, the test `uds_stream::epollhup` expects that a
`UdsStream::connect` future to a Unix socket which is closed by the
accept side to always fail with `io::ErrorKind::ConnectionReset`. On
illumos, and potentially other systems, it instead fails with
`io::ErrorKind::ConnectionRefused`.

This was discovered whilst adding an illumos CI job in PR #6769. See:
https://github.com/tokio-rs/tokio/pull/6769#issuecomment-2284753794

## Solution

This commit changes the test to accept either `ConenctionReset` or
`ConnectionRefused`. This way, we are more tolerant of different
operating systems which may decide to return slightly different errnos
here. Both ECONNREFUSED and ECONNRESET seem reasonable to expect in this
situation, although arguably, ECONNREFUSED is actually more correct: the
acceptor did not accept the connection at all, which seems like
"refusing" it to me...
2024-08-16 10:55:32 +02:00
Eliza Weisman
2d697fc92b
tests: handle spurious EWOULDBLOCK in io_async_fd (#6776)
* tests: handle spurious EWOULDBLOCK in io_async_fd

## Motivation

The `io_async_fd.rs` tests contain a `drain()` function, which
currently performs synchronous reads from a UDS socket until it returns
`io::ErrorKind::WouldBlock` (i.e., errno `EWOULDBLOCK`/`EAGAIN`). The
*intent* behind this function is to ensure that all data has been
drained from the UDS socket's buffer...which is what it appears to
do...on Linux. On other systems, it appears that an `EWOULDBLOCK` or
`EAGAIN` may be returned before enough data has been read from the UDS
socket to result in the other end being notified that the socket is now
writable. In particular, this appears to be the case on illumos, where
the tests using this function hang forever (see [this comment][1] on PR
#6769).

To my knowledge, this behavior is still POSIX-compliant --- the
reader will still be notified that the socket is readable, and if it
were actually doing non-blocking IO, it would continue reading upon
receipt of that notification. So, relying on `EWOULDBLOCK` to indicate
that the socket has been sufficiently drained appears to rely on
Linux/FreeBSD behavior that isn't necessarily portable to other Unices.

## Solution

This commit changes the `drain()` function to take an argument for the
number of bytes *written* to the socket previously, and continue looping
until it has read that many bytes, regardless of whether `EWOULDBLOCK`
is returned. This should ensure that the socket is drained on all
POSIX-compliant systems, and indeed, the `io_async_fd::reset_writable`
and `io_async_fd::poll_fns` tests no longer hang forever on illumos.

I think making this change is an appropriate solution to the
test failure here, as the `drain()` function is part of the test, rather
than the code in Tokio *being* tested, and (as I mentioned above) the
use of blocking reads on a non-blocking socket without a mechanism to
continue reading when the socket becomes readable again is not really
something a real life program seems likely to do. Ensuring that all the
written bytes have been read by passing in a byte count seems more
faithful to what the test is actually *trying* to do here, anyway.

Thanks to @jclulow for debugging what was going on here!

This change was cherry-picked from commit
f18d6ed7d4e0724bbe14db5519d7c80b3227a1a9 from PR #6769, so that the fix
can be merged separately.

[1]: https://github.com/tokio-rs/tokio/pull/6769#issuecomment-2284753794

Signed-off-by: Eliza Weisman <eliza@elizas.website>
2024-08-15 15:44:36 +00:00
Rafael Bachmann
39c3c19bbd
macros: improve documentation for select! (#6774) 2024-08-14 15:49:28 +02:00
Vrtgs
17819062e2
tokio: update code according to new MSRV (#6764) 2024-08-11 11:55:22 +02:00
Sainath Singineedi
6ad1912353
task: add #[must_use] to JoinHandle::abort_handle (#6762) 2024-08-09 20:57:31 +00:00
Caleb Leinz (he/him)
a491b16a89
sync: add {TrySendError,SendTimeoutError}::into_inner (#6755) 2024-08-08 00:06:37 +02:00
Austin Bonander
0ecf5f0f03
task: include panic msg when printing JoinError (#6753) 2024-08-07 16:54:02 +02:00
Alice Ryhl
ab53bf0c47
runtime: prevent niche-optimization to avoid triggering miri (#6744) 2024-08-03 12:32:50 +02:00
Motoyuki Kimura
338e13b04b
task: use NonZeroU64 for task::Id (#6733) 2024-08-01 14:45:35 +00:00
Motoyuki Kimura
1077b0b29d
io: use vectored io for write_all_buf when possible (#6724) 2024-07-29 19:39:44 +02:00
Hayden Stainsby
0cbf1a5ada
time,sync: make Sleep and BatchSemaphore instrumentation explicit roots (#6727)
When instrumenting resources in Tokio, a span is created for each
resource. Previously, all resources inherited the currently active span
as their parent (tracing default). However, this would keep that parent
span alive until the resource (and its span) were dropped. This is often
not correct, as a resource may be created in a task and then sent
elsewhere, while the originating task ends.

This artificial extension of the parent span's lifetime would make it
look like that task was still alive (but idle) in any system reading the
tracing instrumentation in Tokio, for example Tokio Console as reported
in tokio-rs/console#345.

In #6107, most of the existing resource spans were updated to
make them explicit roots, so they have no contextual parent. However,
2. were missed:
- `Sleep`
- `BatchSemaphore`

This change alters the resource spans for those 2 resources to also make
them explicit roots.
2024-07-29 12:06:13 +02:00
Hayden Stainsby
04c2718508
docs: reiterate that [build] doesn't go in Cargo.toml (#6728)
To enable unstable features in Tokio, passing `--cfg tokio_unstable` to
the compiler is necessary. We document how to do this in a variety of
ways in the main Tokio (lib.rs) documentation.

One way is to add a `[build]` section to the file `.cargo/config.toml`.
Even though this filename is stated in the documentation, it is quite
common that first time users (including this author, some time ago) put
it in their `Cargo.toml` file instead.

This change adds a "warning" section to the documentation to reiterate
the point that this section doesn't go in the cargo manifest
(`Cargo.toml`).
2024-07-29 11:23:29 +02:00
Niklas Fiekas
ebda4c3d3f
process: stabilize Command::process_group (#6731) 2024-07-27 23:08:40 +02:00
Alice Ryhl
f602eae499
chore: prepare Tokio v1.39.2 (#6730) 2024-07-27 12:36:48 +02:00
Alice Ryhl
438def7957
macros: allow temporary lifetime extension in select (#6722) 2024-07-26 17:36:28 +01:00
Motoyuki Kimura
ee8d4d1b05
chore: fix ci failures (#6725) 2024-07-25 20:30:23 +02:00
Alice Ryhl
f8fe0ffb23
chore: prepare Tokio v1.39.1 (#6716) 2024-07-23 18:28:04 +02:00
Alice Ryhl
47210a8e6e
time: revert "avoid traversing entries in the time wheel twice" (#6715)
This reverts commit 8480a180e6ffdd0ec0ec213a9bebcda2445fc541.
2024-07-23 16:09:28 +00:00
Alice Ryhl
29545d9037
runtime: ignore many_oneshot_futures test for alt scheduler (#6712) 2024-07-23 16:35:20 +02:00
Alice Ryhl
48e35c11d9
chore: release Tokio v1.39.0 (#6711) 2024-07-23 15:30:11 +02:00
Alice Ryhl
dd1d37167d
macros: accept IntoFuture args for macros (#6710) 2024-07-23 12:52:25 +00:00
Alice Ryhl
6a1a7b1591
chore: prepare tokio-macros v2.4.0 (#6707) 2024-07-23 14:45:06 +02:00
Kenny Kerr
51b03f0334
deps: update to windows-sys v0.52 (#6154) 2024-07-23 14:43:23 +02:00
Thomas de Zeeuw
754a1fb03c
deps: update to Mio v1 (#6635) 2024-07-23 14:26:07 +02:00
Sebastian Urban
90b23a9584
metrics: add worker thread id (#6695) 2024-07-23 12:41:33 +02:00
Sebastian Urban
b69f16aa21
metrics: add worker_park_unpark_count (#6696) 2024-07-23 09:15:54 +02:00
Alex Butler
6e845b794d
time: support IntoFuture with timeout (#6666) 2024-07-22 23:29:18 +02:00
Alice Ryhl
9681ce2b95
chore: make 1.38 an LTS (#6706) 2024-07-22 23:22:12 +02:00
Tim Vilgot Mikael Fredenberg
feb742c58e
chore: replace num_cpus with available_parallelism (#6709) 2024-07-22 23:15:23 +02:00
Alice Ryhl
15cd5146d4
chore: increase MSRV to 1.70 (#6645) 2024-07-22 18:01:27 +00:00
Alice Ryhl
56f4bc6543
chore: make 1.38 an LTS (#6706) 2024-07-21 18:28:12 +02:00
Motoyuki Kimura
3ad5b6df1a
runtime: add cfg for loom specific code (#6694) 2024-07-21 17:26:36 +02:00
Russell Cohen
1be8a8e691
metrics: stabilize num_alive_tasks (#6619) 2024-07-18 22:08:29 +02:00
Motoyuki Kimura
da17c61464
task: add size check for user-supplied future (#6692) 2024-07-18 11:54:37 +00:00