2240 Commits

Author SHA1 Message Date
Jacob O'Toole
1f862d2e95
sync: add watch::Sender::borrow() (#3269) 2020-12-13 20:46:11 -08:00
Sylvain Kerkour
9149d7bfae
docs: mention blocking thread timeout in src/lib.rs (#3253) 2020-12-13 16:24:16 +01:00
cssivision
4c55419453
net: add UnixStream readiness and non-blocking ops (#3246) 2020-12-13 16:21:11 +01:00
Aldas
f26f444f42
doc: added tracing to the feature flags section (#3254) 2020-12-13 15:26:56 +01:00
cssivision
be2cb7a5ce
net: check for false-positives in TcpStream::ready doc test (#3255) 2020-12-13 15:24:59 +01:00
Sunjay Varma
df20c162ae
sync: add blocking_recv method to UnboundedReceiver, similar to Receiver::blocking_recv (#3262) 2020-12-12 08:47:35 -08:00
Alice Ryhl
c1ec469ad2
util: add constructors to TokioContext (#3221) 2020-12-11 20:41:22 -08:00
Lucio Franco
b01b2dacf2
net: update TcpStream::poll_peek to use ReadBuf (#3259)
Closes #2987
2020-12-11 20:40:24 -08:00
Evan Cameron
68717c7efa
net: remove empty udp module (#3260) 2020-12-11 14:45:57 -05:00
Alice Ryhl
69e62ef89e
sync: make TryAcquireError public (#3250)
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-10 19:56:05 -08:00
Nylonicious
16c2e0983c
net: Pass SocketAddr by value (#3125) 2020-12-10 14:58:27 -05:00
Yusuke Tanaka
4b1d76ec8f
docs: fix typo in signal module documentation (#3249) 2020-12-10 08:11:45 -08:00
Clemens Koza
9646b4bce3
toml: enable test-util feature for the playground (#3224) 2020-12-10 10:39:05 +01:00
Alice Ryhl
f60860af7e
watch: fix spurious wakeup (#3234)
Co-authored-by: @tijsvd
2020-12-10 09:46:01 +01:00
cssivision
2a30e13f38
net: expose poll_* methods on UnixDatagram (#3223) 2020-12-10 08:36:43 +01:00
Nylonicious
52cd240053
task: add missing feature flags for task_local and spawn_blocking (#3237) 2020-12-09 23:49:28 +01:00
Carl Lerche
473ddaa277
chore: prepare for Tokio 1.0 work (#3238) 2020-12-09 09:42:05 -08:00
bdonlan
9706ca92a8
time: Fix race condition in timer drop (#3229)
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-08 16:42:43 -08:00
Blas Rodriguez Irizar
fc7a4b3c6e
chore: fix stress test (#3233) 2020-12-09 07:38:25 +09:00
Blas Rodriguez Irizar
e01391351b
Add stress test (#3222)
Created a simple echo TCP server that on two different runtimes that is
called from a GitHub action using Valgrind to ensure that there are
no memory leaks.

Fixes: #3022
2020-12-07 21:12:22 -08:00
bdonlan
57dffb9dfe
rt: fix deadlock in shutdown (#3228)
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-07 20:55:02 -08:00
Carl Lerche
62023dffe5
sync: forward port 0.2 mpsc test (#3225)
Forward ports the test included in #3215. The mpsc sempahore has been
replaced in 0.3 and does not include the bug being fixed.
2020-12-07 11:24:15 -08:00
Fuyang Liu
0707f4c192
net: add TcpStream::into_std (#3189) 2020-12-06 14:33:04 +01:00
Iban Eguia
0dbba13984
deps: replace lazy_static with once_cell (#3187) 2020-12-04 10:23:13 +01:00
John-John Tedro
a125ebd745
rt: fix panic in task abort when off rt (#3159)
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-03 21:29:59 -08:00
Eliza Weisman
00500d1b35
util: prepare v0.5.1 release (#3210)
### Added

- io: `poll_read_buf` util fn (#2972).
- io: `poll_write_buf` util fn with vectored write support (#3156).

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
tokio-util-0.5.1
2020-12-03 15:30:52 -08:00
Eliza Weisman
647299866a
util: add writev-aware poll_write_buf (#3156)
## Motivation

In Tokio 0.2, `AsyncRead` and `AsyncWrite` had `poll_write_buf` and
`poll_read_buf` methods for reading and writing to implementers of
`bytes` `Buf` and `BufMut` traits. In 0.3, these were removed, but
`poll_read_buf` was added as a free function in `tokio-util`. However,
there is currently no `poll_write_buf`.

Now that `AsyncWrite` has regained support for vectored writes in #3149,
there's a lot of potential benefit in having a `poll_write_buf` that
uses vectored writes when supported and non-vectored writes when not
supported, so that users don't have to reimplement this.

## Solution

This PR adds a `poll_write_buf` function to `tokio_util::io`, analogous
to the existing `poll_read_buf` function.

This function writes from a `Buf` to an `AsyncWrite`, advancing the
`Buf`'s internal cursor. In addition, when the `AsyncWrite` supports
vectored writes (i.e. its `is_write_vectored` method returns `true`),
it will use vectored IO.

I copied the documentation for this functions from the docs from Tokio
0.2's `AsyncWrite::poll_write_buf` , with some minor modifications as
appropriate.

Finally, I fixed a minor issue in the existing docs for `poll_read_buf`
and `read_buf`, and updated `tokio_util::codec` to use `poll_write_buf`.

Signed-off-by: Eliza Weisman <eliza@buoyant.io>
2020-12-03 11:19:16 -08:00
Blas Rodriguez Irizar
a6051a61ec
sync: make add_permits panic with usize::MAX >> 3 permits (#3188) 2020-12-02 22:58:28 +01:00
cssivision
a8e0f0a919
example: add back udp-codec example (#3205) 2020-12-01 12:20:20 +09:00
Alan Somers
7ae8135b62
process: fix the process_kill_on_drop.rs test on non-Linux systems (#3203)
"disown" is a bash builtin, not part of POSIX sh.
2020-12-01 10:20:49 +09:00
Alan Somers
353b0544a0
ci: reenable CI on FreeBSD i686 (#3204)
It was temporarily disabled in 06c473e62842d257ed275497ce906710ea3f8e19
and never reenabled.
2020-12-01 10:20:18 +09:00
Alan Somers
128495168d
ci: switch FreeBSD CI environment to 12.2-RELEASE (#3202)
12.1 will be EoL in two months.
2020-12-01 10:19:54 +09:00
Carl Lerche
08548583b9
chore: prepare v0.3.5 release (#3201) tokio-0.3.5 2020-11-30 12:57:31 -08:00
HK416-is-all-you-need
7707ba88ef
io: add AsyncFd::with_interest (#3167)
Fixes #3072
2020-11-30 11:11:18 -08:00
Ivan Tham
72d6346c0d
macros: #[tokio::main] can be used on non-main (#3199) 2020-11-30 17:34:11 +01:00
Kyle Kosic
a85fdb884d
runtime: test for shutdown_timeout(0) (#3196) 2020-11-29 21:30:19 +01:00
Alice Ryhl
c55d846f4b
util: add rt to tokio-util full feature (#3194) 2020-11-29 09:48:31 +01:00
Max Sharnoff
0acd06b42a
runtime: fix shutdown_timeout(0) blocking (#3174) 2020-11-28 19:31:13 +01:00
Niklas Fiekas
4912943419
signal: expose CtrlC stream on windows (#3186)
* Make tokio::signal::windows::ctrl_c() public.
* Stop referring to private tokio::signal::windows::Event in module
  documentation.

Closes #3178
2020-11-27 19:53:17 +00:00
Rajiv Chauhan
5e406a7a47
macros: fix outdated documentation (#3180)
1. Changed 0.2 to 0.3
2. Changed ‘multi’ to ‘single’ to indicate that the behavior is single threaded
2020-11-26 19:46:15 +01:00
Max Sharnoff
de33ee85ce
time: replace 'ouClockTimeide' in internal docs with 'outside' (#3171) 2020-11-24 10:23:20 +01:00
漂流
874fc3320b
codec: add read_buffer_mut to FramedRead (#3166) 2020-11-24 09:39:16 +01:00
bdonlan
ae67851f11
time: use intrusive lists for timer tracking (#3080)
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-23 10:42:50 -08:00
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