2174 Commits

Author SHA1 Message Date
Oliver Gould
c2e843d928
tokio-test: Update bytes to v0.6 (#3107) 2020-11-08 05:54:41 +09:00
bdonlan
a43ec09b55
async_fd: make into_inner() deregister the fd (#3104)
* async_fd: make into_inner() deregister the fd

Fixes: #3103

* make clippy happy

Co-authored-by: Bryan Donlan <bdonlan@amazon.com>
2020-11-07 10:12:06 +01:00
Maarten de Vries
90c2a510e2
net: report PID in UCred for Solaris and Illumos. (#3085) 2020-11-06 17:04:19 +01:00
Alice Ryhl
f51ddc5958
net: add set_nonblocking to doc (#3100) 2020-11-06 17:01:22 +01:00
Evan Cameron
47658a6da5
util: resurrect UdpFramed (#3044) 2020-11-06 16:59:15 +01:00
bdonlan
d7e3fcb9ee
rt: remove last slab dependency (#2917)
This removes the last slab dependency by replacing the current slab-based
JoinHandle tracking with one based on HashMap instead.

Co-authored-by: Bryan Donlan <bdonlan@amazon.com>
2020-11-05 10:38:37 -08:00
Marc-Antoine Perennou
0b3918bce9
rt: bring back a public Handle type (#3076)
Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
Co-authored-by: Alice Ryhl <alice@ryhl.io>
Co-authored-by: Carl Lerche <me@carllerche.com>
2020-11-05 13:00:13 +01:00
Akira Hayakawa
e309da0bee
util: remove stream feature flag from DelayQueue (#3087) 2020-11-03 09:20:24 +01:00
Carl Lerche
bbc8eb0f91
chore: update CI badge (#3091) 2020-11-03 09:17:47 +01:00
Artem Vorotnikov
06c7e73e99
stream: fix StreamMap Default bound (#3093) 2020-11-03 09:09:05 +01:00
Carl Lerche
42de3bc7a4
chore: prepare v0.3.3 release (#3090) tokio-0.3.3 2020-11-02 15:36:17 -08:00
Alice Ryhl
20a2b9e263
rt: add missing Send bound (#3089) 2020-11-02 15:30:07 -08:00
Zeki Sherif
ae4e8d7ad1
net: add get/set reuseport, reuseaddr, localaddr for TcpSocket (#3083) 2020-11-02 12:59:56 -08:00
Alice Ryhl
7a18ca2be0
doc: add from_std change to CHANGELOG (#3075) 2020-11-02 10:25:43 -08:00
Naja Melan
4a7b7c52d1
util: copy paste error in documentation for Compat (#3088) 2020-11-02 13:25:51 +01:00
Eliza Weisman
fede3db76a
tracing: replace future names with spawn locations in task spans (#3074)
## Motivation

Currently, the per-task `tracing` spans generated by tokio's `tracing`
feature flag include the `std::any::type_name` of the future that was
spawned. When future combinators and/or libraries like Tower are in use,
these future names can get _quite_ long. Furthermore, when formatting
the `tracing` spans with their parent spans as context, any other task
spans in the span context where the future was spawned from can _also_
include extremely long future names.

In some cases, this can result in extremely high memory use just to
store the future names. For example, in Linkerd, when we enable
`tokio=trace` to enable the task spans, there's a spawned task whose
future name is _232990 characters long_. A proxy with only 14 spawned
tasks generates a task list that's over 690 KB. Enabling task spans
under load results in the process getting OOM killed very quickly.

## Solution

This branch removes future type names from the spans generated by
`spawn`. As a replacement, to allow identifying which `spawn` call a
span corresponds to, the task span now contains the source code location
where `spawn` was called, when the compiler supports the
`#[track_caller]` attribute. Since `track_caller` was stabilized in Rust
1.46.0, and our minimum supported Rust version is 1.45.0, we can't
assume that `#[track_caller]` is always available. Instead, we have a
RUSTFLAGS cfg, `tokio_track_caller`, that guards whether or not we use
it. I've also added a `build.rs` that detects the compiler minor
version, and sets the cfg flag automatically if the current compiler
version is >= 1.46. This means users shouldn't have to enable
`tokio_track_caller` manually.

Here's the trace output from the `chat` example, before this change:
![Screenshot_20201030_110157](https://user-images.githubusercontent.com/2796466/97741071-6d408800-1a9f-11eb-9ed6-b25e72f58c7b.png)
...and after:
![Screenshot_20201030_110303](https://user-images.githubusercontent.com/2796466/97741112-7e899480-1a9f-11eb-9197-c5a3f9ea1c05.png)

Closes #3073

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2020-11-01 10:48:44 -08:00
Dirkjan Ochtman
2b23aa7389
util: add back public poll_read_buf() function (#3079)
This was accidentally removed in #3064.
2020-11-01 10:22:22 +01:00
Finn Behrens
382ee6bf5d
net: add pid to tokio::net::unix::UCred (#2633) 2020-10-31 10:30:55 +01:00
Carl Lerche
24ed874e81
chore: prepare tokio-util v0.5.0 release (#3078) tokio-util-0.5.0 2020-10-30 11:26:15 -07:00
Dirkjan Ochtman
3965d91a5e
util: update to bytes 0.6 (#3071)
Copies the implementation of poll_read_buf() from tokio::io::util::read_buf.
2020-10-29 10:45:19 -07:00
Dirkjan Ochtman
a3ef4e4cf5
util: deduplicate implementations of poll_read_buf() (#3064) 2020-10-29 13:20:38 +01:00
Naja Melan
34eb47dde5
runtime: block_on should NOT be called from async context (#3070) 2020-10-29 12:10:42 +01:00
Tom Kaitchuck
c8a484bbb2
tokio: remove unused dependency (#3063)
Signed-off-by: Tom Kaitchuck <Tom.Kaitchuck@gmail.com>
2020-10-28 08:06:53 +01:00
Carl Lerche
9097ae548f
chore: prepare v0.3.2 release (#3059) tokio-0.3.2 2020-10-27 14:31:39 -07:00
Carl Lerche
d78655337a
Revert "util: upgrade tokio-util to bytes 0.6 (#3052)" (#3060)
This reverts commit fe2b997.

We are avoiding adding poll_read_buf to tokio itself for now. The patch is
reverted now in order to not block the v0.3.2 release (#3059).
2020-10-27 13:42:00 -07:00
Zahari Dichev
38605c5c85
net: change mention of net2 (#3056) 2020-10-27 09:34:17 -07:00
Dirkjan Ochtman
fe2b997675
util: upgrade tokio-util to bytes 0.6 (#3052) 2020-10-27 09:30:29 +01:00
Sean McArthur
6d0ba19af5
sync: make oneshot::Sender::poll_closed public again (#3032) 2020-10-26 08:54:25 -07:00
Alice Ryhl
cbb8fe6069
udp: add UdpSocket::take_error (#3051) 2020-10-26 12:50:48 +01:00
Alice Ryhl
a9da220923
oneshot: update closed() docs to use tokio::select! (#3050) 2020-10-26 11:44:46 +01:00
Alice Ryhl
1c28c3b0a8
macros: prepare tokio-macros 0.3.1 (#3042) tokio-macros-0.3.1 2020-10-26 10:02:39 +01:00
nickelc
e31bd321ef
readme: update the MSRV to 1.45 (#3048) 2020-10-26 09:46:15 +01:00
nickelc
c30ce1f65c
docs: remove max_threads mentions in tokio-macros (#3038) 2020-10-24 22:34:56 +02:00
Alice Ryhl
a95378a850
io: expand on de-initialization of ReadBuf (#3035) 2020-10-24 22:29:19 +02:00
Zahari Dichev
ce173fdc91
docs: update docs for from_std functions (#3016)
Fixes: #3007
2020-10-24 14:26:01 +02:00
Zahari Dichev
e804f88d60
sync: add mem::forget to RwLockWriteGuard::downgrade. (#2957)
Currently when `RwLockWriteGuard::downgrade` the `MAX_READS - 1`
permits are added to the semaphore. When `RwLockWriteGuard::drop`
gets invoked however another `MAX_READS` permits are added. This
results in releasing more permits that were actually aquired when
downgrading a write to a read lock. This is why we need to call
`mem::forget` on the `RwLockWriteGuard` in order to avoid
invoking the destructor.

Fixes: #2941
2020-10-23 10:07:00 -07:00
bdonlan
c153913211
io: Add AsyncFd, fix io::driver shutdown (#2903)
* io: Add AsyncFd

This adds AsyncFd, a unix-only structure to allow for read/writability states
to be monitored for arbitrary file descriptors.

Issue: #2728

* driver: fix shutdown notification unreliability

Previously, there was a race window in which an IO driver shutting down could
fail to notify ScheduledIo instances of this state; in particular, notification
of outstanding ScheduledIo registrations was driven by `Driver::drop`, but
registrations bypass `Driver` and go directly to a `Weak<Inner>`. The `Driver`
holds the `Arc<Inner>` keeping `Inner` alive, but it's possible that a new
handle could be registered (or a new readiness future created for an existing
handle) after the `Driver::drop` handler runs and prior to `Inner` being
dropped.

This change fixes this in two parts: First, notification of outstanding
ScheduledIo handles is pushed down into the drop method of `Inner` instead,
and, second, we add state to ScheduledIo to ensure that we remember that the IO
driver we're bound to has shut down after the initial shutdown notification, so
that subsequent readiness future registrations can immediately return (instead
of potentially blocking indefinitely).

Fixes: #2924
2020-10-22 14:12:41 -07:00
Evan Cameron
358e4f9f80
tokio: add back poll_* for udp (#2981) 2020-10-22 09:58:00 -07:00
Zhang Jingqiang
adf822f5cc
net: fix typo (#3023) 2020-10-22 08:59:47 +02:00
Carl Lerche
d14cbf9116
chore: prepare v0.3.1 release (#3021) tokio-0.3.1 2020-10-21 16:23:35 -07:00
Carl Lerche
8bfb1c92ce
sync: revert Clone impl for broadcast::Receiver (#3020)
The `Receiver` handle maintains a position in the broadcast channel for
itself. Cloning implies copying the state of the value. Intuitively,
cloning a `broadcast::Receiver` would return a new receiver with an
identical position. However, the current implementation returns a new
`Receiver` positioned at the tail of the channel.

This behavior subtlety is why `new_subscriber()` is used to create
`Receiver` handles. An alternate API should consider the position issue.

Refs: #2933
2020-10-21 15:14:52 -07:00
Carl Lerche
b48fec9655
net: fix use-after-free in slab compaction (#3019)
An off-by-one bug results in freeing the incorrect page. This
also adds an `asan` CI job.

Fixes: 3014
2020-10-21 14:43:57 -07:00
Carl Lerche
8dbc3c7937
io: add AsyncReadExt::read_buf (#3003)
Brings back `read_buf` from 0.2. This will be stabilized as part of 1.0.
2020-10-21 14:08:49 -07:00
Marc-Antoine Perennou
7fbfa9b649
tokio: deduplicate spawn_blocking (#3017)
Move common code and tracing integration into Handle

Fixes #2998
Closes #3004

Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
2020-10-21 20:00:48 +02:00
Nikolai Kuklin
7d7b79e1d5
sync: add is_closed method to watch sender (#2991) 2020-10-21 13:35:13 +02:00
Zahari Dichev
8f37544a79
io: explain how to determine number of bytes read in AsyncRead (#3011)
Fixes: #2999
2020-10-21 13:32:50 +02:00
Philip Kannegaard Hayes
43d0714898
sync: remove extra clone in Semaphore::[try_]acquire_owned (#3015) 2020-10-21 08:16:03 +02:00
Zahari Dichev
16e272ea4b
fs: flush on shutdown (#3009)
Fixes: #2950
2020-10-20 17:42:32 +02:00
John-John Tedro
6d99e1c7de
util: prevent read buffer from being swapped during a read_poll (#2993) 2020-10-20 11:14:02 +02:00
pluth
f73a2ad238
docs: adjust TcpListener::from_std documentation to match behavior (#3002) 2020-10-19 21:37:00 -07:00