summaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)Author
2020-11-12net: add TcpStream::ready and non-blocking ops (#3130)Carl Lerche
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-12fs: small documentation fixes (#3133)Nylonicious
2020-11-11ci: minimal version check (#3131)Alice Ryhl
2020-11-11time: document maximum sleep duration (#3126)Alice Ryhl
2020-11-11stream: add docs regarding futures' StreamExt (#3128)Alice Ryhl
2020-11-11process: fix potential file descriptor leak (#3129)Ivan Petkov
2020-11-11io: driver internal cleanup (#3124)Carl Lerche
* 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-10Minor cleanup of parking_lot feature, now in full (#3119)David Kellum
## 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-10io: update AsyncFd to use Registration (#3113)Carl Lerche
2020-11-10sync: add acquire_many and try_acquire_many to `Sempahore` (#3067)Darius Carrier
Fixes: #1550
2020-11-08chore: update proptest and nix (#3110)Taiki Endo
2020-11-08tokio-test: Update bytes to v0.6 (#3107)Oliver Gould
2020-11-07async_fd: make into_inner() deregister the fd (#3104)bdonlan
* async_fd: make into_inner() deregister the fd Fixes: #3103 * make clippy happy Co-authored-by: Bryan Donlan <bdonlan@amazon.com>
2020-11-06net: report PID in UCred for Solaris and Illumos. (#3085)Maarten de Vries
2020-11-06net: add set_nonblocking to doc (#3100)Alice Ryhl
2020-11-06util: resurrect UdpFramed (#3044)Evan Cameron
2020-11-05rt: remove last slab dependency (#2917)bdonlan
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-05rt: bring back a public Handle type (#3076)Marc-Antoine Perennou
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-03util: remove stream feature flag from DelayQueue (#3087)Akira Hayakawa
2020-11-03chore: update CI badge (#3091)Carl Lerche
2020-11-03stream: fix StreamMap Default bound (#3093)Artem Vorotnikov
2020-11-02chore: prepare v0.3.3 release (#3090)Carl Lerche
2020-11-02rt: add missing Send bound (#3089)Alice Ryhl
2020-11-02net: add get/set reuseport, reuseaddr, localaddr for TcpSocket (#3083)Zeki Sherif
2020-11-02doc: add from_std change to CHANGELOG (#3075)Alice Ryhl
2020-11-02util: copy paste error in documentation for Compat (#3088)Naja Melan
2020-11-01tracing: replace future names with spawn locations in task spans (#3074)Eliza Weisman
## 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-01util: add back public poll_read_buf() function (#3079)Dirkjan Ochtman
This was accidentally removed in #3064.
2020-10-31net: add pid to tokio::net::unix::UCred (#2633)Finn Behrens
2020-10-30chore: prepare tokio-util v0.5.0 release (#3078)Carl Lerche
2020-10-29util: update to bytes 0.6 (#3071)Dirkjan Ochtman
Copies the implementation of poll_read_buf() from tokio::io::util::read_buf.
2020-10-29util: deduplicate implementations of poll_read_buf() (#3064)Dirkjan Ochtman
2020-10-29runtime: block_on should NOT be called from async context (#3070)Naja Melan
2020-10-28tokio: remove unused dependency (#3063)Tom Kaitchuck
Signed-off-by: Tom Kaitchuck <Tom.Kaitchuck@gmail.com>
2020-10-27chore: prepare v0.3.2 release (#3059)Carl Lerche
2020-10-27Revert "util: upgrade tokio-util to bytes 0.6 (#3052)" (#3060)Carl Lerche
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-27net: change mention of net2 (#3056)Zahari Dichev
2020-10-27util: upgrade tokio-util to bytes 0.6 (#3052)Dirkjan Ochtman
2020-10-26sync: make oneshot::Sender::poll_closed public again (#3032)Sean McArthur
2020-10-26udp: add UdpSocket::take_error (#3051)Alice Ryhl
2020-10-26oneshot: update closed() docs to use tokio::select! (#3050)Alice Ryhl
2020-10-26macros: prepare tokio-macros 0.3.1 (#3042)Alice Ryhl
2020-10-26readme: update the MSRV to 1.45 (#3048)nickelc
2020-10-24docs: remove `max_threads` mentions in tokio-macros (#3038)nickelc
2020-10-24io: expand on de-initialization of ReadBuf (#3035)Alice Ryhl
2020-10-24docs: update docs for `from_std` functions (#3016)Zahari Dichev
Fixes: #3007
2020-10-23sync: add mem::forget to RwLockWriteGuard::downgrade. (#2957)Zahari Dichev
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-22io: Add AsyncFd, fix io::driver shutdown (#2903)bdonlan
* 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-22tokio: add back poll_* for udp (#2981)Evan Cameron
2020-10-22net: fix typo (#3023)Zhang Jingqiang