summaryrefslogtreecommitdiffstats
path: root/tokio/src
AgeCommit message (Collapse)Author
2020-12-12sync: add blocking_recv method to UnboundedReceiver, similar to ↵HEADmasterSunjay Varma
Receiver::blocking_recv (#3262)
2020-12-11net: update `TcpStream::poll_peek` to use `ReadBuf` (#3259)Lucio Franco
Closes #2987
2020-12-11net: remove empty udp module (#3260)Evan Cameron
2020-12-10sync: make TryAcquireError public (#3250)Alice Ryhl
The [`Semaphore::try_acquire`][1] method currently returns a private error type. [1]: https://docs.rs/tokio/0.3/tokio/sync/struct.Semaphore.html#method.try_acquire
2020-12-10net: Pass SocketAddr by value (#3125)Nylonicious
2020-12-10docs: fix typo in signal module documentation (#3249)Yusuke Tanaka
2020-12-10watch: fix spurious wakeup (#3234)Alice Ryhl
Co-authored-by: @tijsvd
2020-12-10net: expose poll_* methods on UnixDatagram (#3223)cssivision
2020-12-09task: add missing feature flags for task_local and spawn_blocking (#3237)Nylonicious
2020-12-09chore: prepare for Tokio 1.0 work (#3238)Carl Lerche
2020-12-08time: Fix race condition in timer drop (#3229)bdonlan
Dropping a timer on the millisecond that it was scheduled for, when it was on the pending list, could result in a panic previously, as we did not record the pending-list state in cached_when. Hopefully fixes: ZcashFoundation/zebra#1452
2020-12-07rt: fix deadlock in shutdown (#3228)bdonlan
Previously, the runtime shutdown logic would first-hand control over all cores to a single thread, which would sequentially shut down all tasks on the core and then wait for them to complete. This could deadlock when one task is waiting for a later core's task to complete. For example, in the newly added test, we have a `block_in_place` task that is waiting for another task to be dropped. If the latter task adds its core to the shutdown list later than the former, we end up waiting forever for the `block_in_place` task to complete. Additionally, there also was a bug wherein we'd attempt to park on the parker after shutting it down which was fixed as part of the refactors above. This change restructures the code to bring all tasks to a halt (and do any parking needed) before we collapse to a single thread to avoid this deadlock. There was also an issue in which canceled tasks would not unpark the originating thread, due to what appears to be some sort of optimization gone wrong. This has been fixed to be much more conservative in selecting when not to unpark the source thread (this may be too conservative; please take a look at the changes to `release()`). Fixes: #2789
2020-12-06net: add TcpStream::into_std (#3189)Fuyang Liu
2020-12-04deps: replace lazy_static with once_cell (#3187)Iban Eguia
2020-12-03rt: fix panic in task abort when off rt (#3159)John-John Tedro
A call to `JoinHandle::abort` releases a task. When called from outside of the runtime, this panics due to the current implementation checking for a thread-local worker context. This change makes accessing the thread-local context optional under release, by falling back to remotely marking a task remotely as dropped. Behaving the same as if the core was stolen by another worker. Fixes #3157
2020-12-02sync: make add_permits panic with usize::MAX >> 3 permits (#3188)Blas Rodriguez Irizar
2020-11-30chore: prepare v0.3.5 release (#3201)Carl Lerche
2020-11-30io: add AsyncFd::with_interest (#3167)HK416-is-all-you-need
Fixes #3072
2020-11-28runtime: fix shutdown_timeout(0) blocking (#3174)Max Sharnoff
2020-11-27signal: expose CtrlC stream on windows (#3186)Niklas Fiekas
* Make tokio::signal::windows::ctrl_c() public. * Stop referring to private tokio::signal::windows::Event in module documentation. Closes #3178
2020-11-24time: replace 'ouClockTimeide' in internal docs with 'outside' (#3171)Max Sharnoff
2020-11-23time: use intrusive lists for timer tracking (#3080)bdonlan
More-or-less a half-rewrite of the current time driver, supporting the use of intrusive futures for timer registration. Fixes: #3028, #3069
2020-11-18chore: prepare v0.3.4 release (#3152)Carl Lerche
2020-11-18io: add vectored writes to `AsyncWrite` (#3149)Sean McArthur
This adds `AsyncWrite::poll_write_vectored`, and implements it for `TcpStream` and `UnixStream`. Refs: #3135.
2020-11-17net: add SO_LINGER get/set to TcpStream (#3143)Zeki Sherif
2020-11-16net: add UdpSocket readiness and non-blocking ops (#3138)Carl Lerche
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-16sync: add `Notify::notify_waiters` (#3098)Zahari Dichev
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-16net: Add send/recv buf size methods to `TcpSocket` (#3145)Eliza Weisman
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 <eliza@buoyant.io>
2020-11-16net: restore TcpStream::{poll_read_ready, poll_write_ready} (#2743)masnagam
2020-11-13net: add missing doc cfg on TcpSocket (#3137)Carl Lerche
This adds the missing `net` feature flag in the generated API documentation.
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-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-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-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-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-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-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-10-31net: add pid to tokio::net::unix::UCred (#2633)Finn Behrens
2020-10-29runtime: block_on should NOT be called from async context (#3070)Naja Melan