Commit Graph
2197 Commits
Author SHA1 Message Date
Eliza Weisman f927f01a34 macros: fix rustfmt on 1.48.0 (#3160)
## Motivation

Looks like the Rust 1.48.0 version of `rustfmt` changed some formatting
rules (fixed some bugs?), and some of the code in `tokio-macros` is no
longer correctly formatted. This is breaking CI.

## Solution

This commit runs rustfmt on Rust 1.48.0. This fixes CI.

Closes #3158
2020-11-20 10:19:26 -08:00
cssivision 49abfdb2ac util: fix typo in udp/frame.rs (#3154) 2020-11-20 15:06:14 +09:00
Carl Lerche 479c545c20 chore: prepare v0.3.4 release (#3152) tokio-0.3.4 2020-11-18 12:38:13 -08:00
Sean McArthur 34fcef258b io: add vectored writes to AsyncWrite (#3149)
This adds `AsyncWrite::poll_write_vectored`, and implements it for
`TcpStream` and `UnixStream`.

Refs: #3135.
2020-11-18 10:41:47 -08:00
Zeki Sherif 7d11aa8668 net: add SO_LINGER get/set to TcpStream (#3143) 2020-11-17 09:58:00 -08:00
Carl Lerche 0ea2307650 net: add UdpSocket readiness and non-blocking ops (#3138)
Adds `ready()`, `readable()`, and `writable()` async methods for waiting
for socket readiness. Adds `try_send`, `try_send_to`, `try_recv`, and
`try_recv_from` for performing non-blocking operations on the socket.

This is the UDP equivalent of #3130.
2020-11-16 15:44:01 -08:00
Zahari Dichev d0ebb41547 sync: add Notify::notify_waiters (#3098)
This PR makes `Notify::notify_waiters` public. The method
already exists, but it changes the way `notify_waiters`,
is used. Previously in order for the consumer to
register interest, in a notification triggered by
`notify_waiters`, the `Notified` future had to be
polled. This introduced friction when using the api
as the future had to be pinned before polled.

This change introduces a counter that tracks how many
times `notified_waiters` has been called. Upon creation of
the future the number of times is loaded. When first
polled the future compares this number with the count
state of the `Notify` type. This avoids the need for
registering the waiter upfront.

Fixes: #3066
2020-11-16 12:49:35 -08:00
Eliza Weisman f5cb4c2042 net: Add send/recv buf size methods to TcpSocket (#3145)
This commit adds `set_{send, recv}_buffer_size` methods to `TcpSocket`
for setting the size of the TCP send and receive buffers, and `{send,
recv}_buffer_size` methods for returning the current value. These just
call into similar methods on `mio`'s `TcpSocket` type, which were added
in tokio-rs/mio#1384.

Refs: #3082

Signed-off-by: Eliza Weisman <[email protected]>
2020-11-16 12:29:03 -08:00
masnagam 4e39c9b818 net: restore TcpStream::{poll_read_ready, poll_write_ready} (#2743) 2020-11-16 09:51:06 -08:00
Carl Lerche 97c2c4203c chore: automate running benchmarks (#3140)
Uses Github actions to run benchmarks.
2020-11-13 19:30:52 -08:00
Taiki Endo 60366ca0fa chore: update pin-project-lite to 0.2.0 (#3139) 2020-11-13 15:24:06 -08:00
Carl Lerche 850bfc9efa net: add missing doc cfg on TcpSocket (#3137)
This adds the missing `net` feature flag in the generated API
documentation.
2020-11-13 11:05:22 -08:00
Carl Lerche 02b1117dca net: add TcpStream::ready and non-blocking ops (#3130)
Adds function to await for readiness on the TcpStream and non-blocking read/write functions.

`async fn TcpStream::ready(Interest)` waits for socket readiness satisfying **any** of the specified
interest. There are also two shorthand functions, `readable()` and `writable()`.

Once the stream is in a ready state, the caller may perform non-blocking operations on it using
`try_read()` and `try_write()`. These function return `WouldBlock` if the stream is not, in fact, ready.

The await readiness function are similar to `AsyncFd`, but do not require a guard. The guard in
`AsyncFd` protect against a potential race between receiving the readiness notification and clearing
it. The guard is needed as Tokio does not control the operations. With `TcpStream`, the `try_read()`
and `try_write()` function handle clearing stream readiness as needed.

This also exposes `Interest` and `Ready`, both defined in Tokio as wrappers for Mio types. These
types will also be useful for fixing #3072 .

Other I/O types, such as `TcpListener`, `UdpSocket`, `Unix*` should get similar functions, but this
is left for later PRs.

Refs: #3130
2020-11-12 20:07:43 -08:00
Nylonicious 685da8dadd fs: small documentation fixes (#3133) 2020-11-12 10:24:13 +01:00
Alice Ryhl 6a0e23c654 ci: minimal version check (#3131) 2020-11-11 23:08:34 +01:00
Alice Ryhl 9d0c0dd22c time: document maximum sleep duration (#3126) 2020-11-11 11:31:22 -08:00
Alice Ryhl 6d5423f3e9 stream: add docs regarding futures' StreamExt (#3128) 2020-11-11 11:20:14 -08:00
Ivan Petkov ebb8bab060 process: fix potential file descriptor leak (#3129) 2020-11-11 11:10:27 -08:00
Carl Lerche ce891a4df1 io: driver internal cleanup (#3124)
* Removes duplicated code by moving it to `Registration`.
* impl `Deref` for `PollEvented` to avoid `get_ref()`.
* Avoid extra waker clones in I/O driver.
* Add `Interest` wrapper around `mio::Interest`.
2020-11-11 09:28:21 -08:00
David Kellum d869e16990 Minor cleanup of parking_lot feature, now in full (#3119)
## Motivation

Some small cleanup items are apparent after merge of #2951

## Solution

Delete a now incorrect comment in Cargo.toml, and remove a now redundant CI test step.
2020-11-10 15:01:58 -08:00
Carl Lerche e1256d8ca4 io: update AsyncFd to use Registration (#3113) 2020-11-10 09:40:20 -08:00
Darius Carrier a52f5071bf sync: add acquire_many and try_acquire_many to Sempahore (#3067)
Fixes: #1550
2020-11-10 09:39:30 -08:00
Taiki Endo f1f8c3cde6 chore: update proptest and nix (#3110) 2020-11-08 20:47:44 +09:00
Oliver Gould c2e843d928 tokio-test: Update bytes to v0.6 (#3107) 2020-11-08 05:54:41 +09:00
bdonlanandBryan Donlan 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 <[email protected]>
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
bdonlanandBryan Donlan 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 <[email protected]>
2020-11-05 10:38:37 -08:00
0b3918bce9 rt: bring back a public Handle type (#3076)
Signed-off-by: Marc-Antoine Perennou <[email protected]>
Co-authored-by: Alice Ryhl <[email protected]>
Co-authored-by: Carl Lerche <[email protected]>
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 <[email protected]>
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 <[email protected]>
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