2140 Commits

Author SHA1 Message Date
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
Alice Ryhl
c793ead0c3
runtime: remove unneeded #[cfg(feature = "rt")] (#2996) 2020-10-19 21:35:33 -07:00
Marc-Antoine Perennou
2696794771
tokio: add Runtime::spawn_blocking (#2980)
This allows writing

rt.spawn_blocking(f);

instead of

let _enter = rt.enter();
tokio::task::spawn_blocking(f);

Signed-off-by: Marc-Antoine Perennou <Marc-Antoine@Perennou.com>
2020-10-19 18:49:16 +02:00
nickelc
cfd643d691
docs: fix typo in runtime module documentation (#2992) 2020-10-19 15:33:10 +02:00
John-John Tedro
8d17261a4b
util: add a poll_read_buf shim to tokio-util (#2972) 2020-10-19 11:06:06 +02:00
Zahari Dichev
423ecc187a
io: add copy_buf (#2884) 2020-10-19 10:15:25 +02:00
Zephyr Shannon
fb28caa90c
sync: implement Clone for broadcast::Receiver (#2933) 2020-10-19 10:12:40 +02:00
Evan Cameron
e88e64bcc0
docs: fix typos on UdpSocket (#2979) 2020-10-17 12:13:23 +02:00
messense
3cc6ce7a99
doc: update version to 0.3 in module documentation (#2974) 2020-10-16 13:49:30 +02:00
Alice Ryhl
81db03204d
Fix doc typo (#2967) 2020-10-16 12:37:21 +02:00
John-John Tedro
1644511bdf Update documentation of AsyncRead to reflect use of ReadBuf 2020-10-16 11:55:35 +02:00
Carl Lerche
dc9742fbea
chore: post release Cargo.toml fixes (#2963) 2020-10-15 11:46:10 -07:00
Carl Lerche
12f1dffa2d
chore: prepare for v0.3.0 release (#2960) tokio-0.3.0 2020-10-15 09:22:07 -07:00
Taiki Endo
871289b3e7
ci: run clippy on MSRV (#2962) 2020-10-15 06:30:20 +09:00
Lucio Franco
30b40ef518
rt: update docs for 0.3 changes (#2956)
This PR updates the runtime module docs to the changes made in `0.3`
release of tokio.

Closes #2720
2020-10-13 15:49:19 -07:00
Carl Lerche
22fa883296
rt: tweak spawn_blocking docs (#2955) 2020-10-13 15:07:10 -07:00
Carl Lerche
00b6127f2e
rt: switch enter to an RAII guard (#2954) 2020-10-13 15:06:22 -07:00
Ivan Petkov
a249421abc
process: update docs regarding zombie processes (#2952) 2020-10-13 00:42:17 +00:00
Carl Lerche
1923350880
meta: combine net and dns, use parking_lot (#2951)
This combines the `dns` and `net` feature flags. Previously, `dns` was
included as part of `net`. Given that is is rare that one would want
`dns` without `net`, DNS is now entirely gated w/ `net`.

The `parking_lot` feature is included as part of `full`.

Some misc docs are tweaked to reflect feature flag changes.
2020-10-12 16:06:02 -07:00
Taiki Endo
c90681bd8e
rt: simplify rt-* features (#2949)
tokio:

    merge rt-core and rt-util as rt
    rename rt-threaded to rt-multi-thread

tokio-util:

    rename rt-core to rt

Closes #2942
2020-10-12 14:13:23 -07:00
Ivan Petkov
24d0a0cfa8
chore: refactor runtime driver usage of Either (#2918) 2020-10-12 19:57:22 +00:00
Lucio Franco
07802b2c84
rt: worker_threads must be non-zero (#2947)
Co-authored-by: Alice Ryhl <alice@ryhl.io>
2020-10-12 15:15:40 -04:00
Taiki Endo
891de3271d
net: merge tcp, udp, uds features to net feature (#2943) 2020-10-13 03:36:26 +09:00
Lucio Franco
8880222036
rt: Remove threaded_scheduler() and basic_scheduler() (#2876)
Co-authored-by: Alice Ryhl <alice@ryhl.io>
Co-authored-by: Carl Lerche <me@carllerche.com>
2020-10-12 13:44:54 -04:00
Juan Alvarez
0893841f31
time: move error types into time::error (#2938) 2020-10-12 10:21:44 -07:00
Lucio Franco
ec99e61945
time: Clean up Instant docs to align with std (#2946)
Co-authored-by: Alice Ryhl <alice@ryhl.io>
2020-10-12 13:06:55 -04:00
Lucio Franco
f8c91f2ead
io: Rename ReadBuf methods (#2945)
This changes `ReadBuf::add_filled` to `ReadBuf::advance` and
`ReadBuf::append` to `ReadBuf::put_slice`. This is just a
mechanical change.

Closes #2769
2020-10-12 12:41:40 -04:00
Zahari Dichev
b575082543
sync: change chan closed(&mut self) to closed(&self) (#2939) 2020-10-12 12:09:36 -04:00
Taiki Endo
c4f620cb30
chore: remove use of doc_alias feature (#2944) 2020-10-12 09:42:59 +02:00
Taiki Endo
b047f647b7
net: make UCred fields private (#2936) 2020-10-11 09:31:26 +02:00
Taiki Endo
2e05399f4b
sync: move broadcast error types into broadcast::error module (#2937)
Refs: #2928
2020-10-09 10:10:22 -07:00
Carl Lerche
afe535283c
fs: future proof File (#2930)
Changes inherent methods to take `&self` instead of `&mut self`. This
brings the API in line with `std`.

This patch is implemented by using a `tokio::sync::Mutex` to guard the
internal `File` state. This is not an ideal implementation strategy
doesn't make a big impact compared to having to dispatch operations to a
background thread followed by a blocking syscall.

In the future, the implementation can be improved as we explore async
file-system APIs provided by the operating-system (iocp / io_uring).

Closes #2927
2020-10-09 10:02:55 -07:00
Carl Lerche
ee597347c5
net: switch socket methods to &self (#2934)
Switches various socket methods from &mut self to &self. This uses the intrusive
waker infrastructure to handle multiple waiters.

Refs: #2928
2020-10-09 09:16:42 -07:00
Taiki Endo
41ac1ae2bc
io: make Seek and Copy private (#2935)
Refs: #2928
2020-10-09 08:33:14 -07:00
Juan Alvarez
60d81bbe10
time: rename Delay future to Sleep (#2932) 2020-10-08 20:35:12 -07:00