Skip to content

Commit

Permalink
Merge 'master' and 'tokio-1.20.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Darksonn committed Jul 25, 2022
2 parents c0746b6 + f3e340a commit 0906351
Show file tree
Hide file tree
Showing 154 changed files with 1,780 additions and 642 deletions.
28 changes: 22 additions & 6 deletions .github/workflows/ci.yml
Expand Up @@ -34,16 +34,18 @@ jobs:
runs-on: ubuntu-latest
needs:
- test
- test-unstable
- test-parking_lot
- valgrind
- test-unstable
- miri
- asan
- cross
- features
- minrust
- minimal-versions
- fmt
- clippy
- docs
- valgrind
- loom-compile
- check-readme
- test-hyper
Expand Down Expand Up @@ -195,7 +197,7 @@ jobs:
- name: Install Rust ${{ env.rust_nightly }}
uses: actions-rs/toolchain@v1
with:
toolchain: nightly-2022-07-10
toolchain: nightly
components: miri
override: true
- uses: Swatinem/rust-cache@v1
Expand Down Expand Up @@ -489,9 +491,23 @@ jobs:
- name: Install cargo-wasi
run: cargo install cargo-wasi

# TODO: Expand this when full WASI support lands.
# Currently, this is a bare bones regression test
# for features that work today with wasi.
- name: WASI test tokio full
run: cargo test -p tokio --target wasm32-wasi --features full
env:
CARGO_TARGET_WASM32_WASI_RUNNER: "wasmtime run --"
RUSTFLAGS: --cfg tokio_unstable -Dwarnings

- name: WASI test tokio-util full
run: cargo test -p tokio-util --target wasm32-wasi --features full
env:
CARGO_TARGET_WASM32_WASI_RUNNER: "wasmtime run --"
RUSTFLAGS: --cfg tokio_unstable -Dwarnings

- name: WASI test tokio-stream
run: cargo test -p tokio-stream --target wasm32-wasi --features time,net,io-util,sync
env:
CARGO_TARGET_WASM32_WASI_RUNNER: "wasmtime run --"
RUSTFLAGS: --cfg tokio_unstable -Dwarnings

- name: test tests-integration --features wasi-rt
# TODO: this should become: `cargo hack wasi test --each-feature`
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/stress-test.yml
Expand Up @@ -12,7 +12,7 @@ env:
rust_stable: stable

jobs:
stess-test:
stress-test:
name: Stress Test
runs-on: ubuntu-latest
strategy:
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Expand Up @@ -562,7 +562,7 @@ Tokio ≥1.0.0 comes with LTS guarantees:

The goal of these guarantees is to provide stability to the ecosystem.

## Mininum Supported Rust Version (MSRV)
## Minimum Supported Rust Version (MSRV)

* All Tokio ≥1.0.0 releases will support at least a 6-month old Rust
compiler release.
Expand Down
8 changes: 4 additions & 4 deletions SECURITY.md
@@ -1,13 +1,13 @@
## Report a security issue

The Tokio project team welcomes security reports and is committed to providing prompt attention to security issues. Security issues should be reported privately via [security@tokio.rs](mailto:security@tokio.rs). Security issues should not be reported via the public Github Issue tracker.
The Tokio project team welcomes security reports and is committed to providing prompt attention to security issues. Security issues should be reported privately via [security@tokio.rs](mailto:security@tokio.rs). Security issues should not be reported via the public GitHub Issue tracker.

## Vulnerability coordination

Remediation of security vulnerabilities is prioritized by the project team. The project team coordinates remediation with third-party project stakeholders via [Github Security Advisories](https://help.github.com/en/github/managing-security-vulnerabilities/about-github-security-advisories). Third-party stakeholders may include the reporter of the issue, affected direct or indirect users of Tokio, and maintainers of upstream dependencies if applicable.
Remediation of security vulnerabilities is prioritized by the project team. The project team coordinates remediation with third-party project stakeholders via [GitHub Security Advisories](https://help.github.com/en/github/managing-security-vulnerabilities/about-github-security-advisories). Third-party stakeholders may include the reporter of the issue, affected direct or indirect users of Tokio, and maintainers of upstream dependencies if applicable.

Downstream project maintainers and Tokio users can request participation in coordination of applicable security issues by sending your contact email address, Github username(s) and any other salient information to [security@tokio.rs](mailto:security@tokio.rs). Participation in security issue coordination processes is at the discretion of the Tokio team.
Downstream project maintainers and Tokio users can request participation in coordination of applicable security issues by sending your contact email address, GitHub username(s) and any other salient information to [security@tokio.rs](mailto:security@tokio.rs). Participation in security issue coordination processes is at the discretion of the Tokio team.

## Security advisories

The project team is committed to transparency in the security issue disclosure process. The Tokio team announces security issues via [project Github Release notes](https://github.com/tokio-rs/tokio/releases) and the [RustSec advisory database](https://github.com/RustSec/advisory-db) (i.e. `cargo-audit`).
The project team is committed to transparency in the security issue disclosure process. The Tokio team announces security issues via [project GitHub Release notes](https://github.com/tokio-rs/tokio/releases) and the [RustSec advisory database](https://github.com/RustSec/advisory-db) (i.e. `cargo-audit`).
2 changes: 0 additions & 2 deletions tests-integration/Cargo.toml
Expand Up @@ -7,7 +7,6 @@ publish = false

[[bin]]
name = "test-cat"
required-features = ["rt-process-io-util"]

[[bin]]
name = "test-mem"
Expand All @@ -31,7 +30,6 @@ name = "rt_yield"
required-features = ["rt", "macros", "sync"]

[features]
rt-process-io-util = ["tokio/rt", "tokio/macros", "tokio/process", "tokio/io-util", "tokio/io-std"]
# For mem check
rt-net = ["tokio/rt", "tokio/rt-multi-thread", "tokio/net"]
# For test-process-signal
Expand Down
24 changes: 15 additions & 9 deletions tests-integration/src/bin/test-cat.rs
@@ -1,14 +1,20 @@
//! A cat-like utility that can be used as a subprocess to test I/O
//! stream communication.

use tokio::io::AsyncWriteExt;
use std::io;
use std::io::Write;

#[tokio::main(flavor = "current_thread")]
async fn main() {
let mut stdin = tokio::io::stdin();
let mut stdout = tokio::io::stdout();

tokio::io::copy(&mut stdin, &mut stdout).await.unwrap();

stdout.flush().await.unwrap();
fn main() {
let stdin = io::stdin();
let mut stdout = io::stdout();
let mut line = String::new();
loop {
line.clear();
stdin.read_line(&mut line).unwrap();
if line.is_empty() {
break;
}
stdout.write_all(line.as_bytes()).unwrap();
}
stdout.flush().unwrap();
}
6 changes: 5 additions & 1 deletion tests-integration/tests/macros_main.rs
@@ -1,4 +1,8 @@
#![cfg(all(feature = "macros", feature = "rt-multi-thread"))]
#![cfg(all(
feature = "macros",
feature = "rt-multi-thread",
not(target_os = "wasi")
))]

#[tokio::main]
async fn basic_main() -> usize {
Expand Down
1 change: 1 addition & 0 deletions tests-integration/tests/macros_select.rs
Expand Up @@ -4,6 +4,7 @@ use futures::channel::oneshot;
use futures::executor::block_on;
use std::thread;

#[cfg_attr(target_os = "wasi", ignore = "WASI: std::thread::spawn not supported")]
#[test]
fn join_with_select() {
block_on(async {
Expand Down
16 changes: 3 additions & 13 deletions tests-integration/tests/process_stdio.rs
@@ -1,5 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
#![cfg(all(feature = "full", not(target_os = "wasi")))]

use tokio::io::{AsyncBufReadExt, AsyncReadExt, AsyncWriteExt, BufReader};
use tokio::join;
Expand All @@ -8,22 +8,12 @@ use tokio_test::assert_ok;

use futures::future::{self, FutureExt};
use std::convert::TryInto;
use std::env;
use std::io;
use std::process::{ExitStatus, Stdio};

// so, we need to change this back as a test, but for now this doesn't work because of:
// https://github.com/rust-lang/rust/pull/95469
//
// undo when this is closed: https://github.com/tokio-rs/tokio/issues/4802

// fn cat() -> Command {
// let mut cmd = Command::new(std::env!("CARGO_BIN_EXE_test-cat"));
// cmd.stdin(Stdio::piped()).stdout(Stdio::piped());
// cmd
// }

fn cat() -> Command {
let mut cmd = Command::new("cat");
let mut cmd = Command::new(env!("CARGO_BIN_EXE_test-cat"));
cmd.stdin(Stdio::piped()).stdout(Stdio::piped());
cmd
}
Expand Down
1 change: 1 addition & 0 deletions tokio-stream/Cargo.toml
Expand Up @@ -38,6 +38,7 @@ parking_lot = "0.12.0"
tokio-test = { path = "../tokio-test" }
futures = { version = "0.3", default-features = false }

[target.'cfg(not(target_arch = "wasm32"))'.dev-dependencies]
proptest = "1"

[package.metadata.docs.rs]
Expand Down
2 changes: 1 addition & 1 deletion tokio-stream/tests/stream_panic.rs
@@ -1,5 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "time")]
#![cfg(all(feature = "time", not(target_os = "wasi")))] // Wasi does not support panic recovery

use parking_lot::{const_mutex, Mutex};
use std::error::Error;
Expand Down
1 change: 1 addition & 0 deletions tokio-stream/tests/stream_stream_map.rs
Expand Up @@ -325,6 +325,7 @@ fn one_ready_many_none() {
}
}

#[cfg(not(target_os = "wasi"))]
proptest::proptest! {
#[test]
fn fuzz_pending_complete_mix(kinds: Vec<bool>) {
Expand Down
2 changes: 1 addition & 1 deletion tokio-test/src/macros.rs
Expand Up @@ -260,7 +260,7 @@ macro_rules! assert_err {
}};
}

/// Asserts that an exact duration has elapsed since since the start instant ±1ms.
/// Asserts that an exact duration has elapsed since the start instant ±1ms.
///
/// ```rust
/// use tokio::time::{self, Instant};
Expand Down
1 change: 1 addition & 0 deletions tokio-util/src/lib.rs
Expand Up @@ -29,6 +29,7 @@ cfg_codec! {
}

cfg_net! {
#[cfg(not(target_arch = "wasm32"))]
pub mod udp;
pub mod net;
}
Expand Down
4 changes: 2 additions & 2 deletions tokio-util/src/sync/cancellation_token/tree_node.rs
Expand Up @@ -200,7 +200,7 @@ where
/// `parent` MUST have been a parent of the node when they both got locked,
/// otherwise there is a potential for a deadlock as invariant #2 would be violated.
///
/// To aquire the locks for node and parent, use [with_locked_node_and_parent].
/// To acquire the locks for node and parent, use [with_locked_node_and_parent].
fn move_children_to_parent(node: &mut Inner, parent: &mut Inner) {
// Pre-allocate in the parent, for performance
parent.children.reserve(node.children.len());
Expand All @@ -218,7 +218,7 @@ fn move_children_to_parent(node: &mut Inner, parent: &mut Inner) {
/// Removes a child from the parent.
///
/// `parent` MUST be the parent of `node`.
/// To aquire the locks for node and parent, use [with_locked_node_and_parent].
/// To acquire the locks for node and parent, use [with_locked_node_and_parent].
fn remove_child(parent: &mut Inner, mut node: MutexGuard<'_, Inner>) {
// Query the position from where to remove a node
let pos = node.parent_idx;
Expand Down
2 changes: 1 addition & 1 deletion tokio-util/src/sync/tests/loom_cancellation_token.rs
Expand Up @@ -80,7 +80,7 @@ fn drop_token_no_child() {
}

#[test]
fn drop_token_with_childs() {
fn drop_token_with_children() {
loom::model(|| {
let token1 = CancellationToken::new();
let child_token1 = token1.child_token();
Expand Down
2 changes: 2 additions & 0 deletions tokio-util/src/task/mod.rs
Expand Up @@ -2,7 +2,9 @@

#[cfg(tokio_unstable)]
mod join_map;
#[cfg(not(target_os = "wasi"))]
mod spawn_pinned;
#[cfg(not(target_os = "wasi"))]
pub use spawn_pinned::LocalPoolHandle;

#[cfg(tokio_unstable)]
Expand Down
2 changes: 1 addition & 1 deletion tokio-util/src/time/delay_queue.rs
Expand Up @@ -190,7 +190,7 @@ impl<T> SlabStorage<T> {
let key_contained = self.key_map.contains_key(&key.into());

if key_contained {
// It's possible that a `compact` call creates capacitiy in `self.inner` in
// It's possible that a `compact` call creates capacity in `self.inner` in
// such a way that a `self.inner.insert` call creates a `key` which was
// previously given out during an `insert` call prior to the `compact` call.
// If `key` is contained in `self.key_map`, we have encountered this exact situation,
Expand Down
1 change: 1 addition & 0 deletions tokio-util/tests/context.rs
@@ -1,4 +1,5 @@
#![cfg(feature = "rt")]
#![cfg(not(target_os = "wasi"))] // Wasi doesn't support threads
#![warn(rust_2018_idioms)]

use tokio::runtime::Builder;
Expand Down
2 changes: 1 addition & 1 deletion tokio-util/tests/framed_write.rs
Expand Up @@ -130,7 +130,7 @@ fn write_hits_backpressure() {
_ => unreachable!(),
}

// Push a new new chunk
// Push a new chunk
mock.calls.push_back(Ok(b[..].to_vec()));
}
// 1 'wouldblock', 4 * 2KB buffers, 1 b-byte buffer
Expand Down
1 change: 1 addition & 0 deletions tokio-util/tests/io_sync_bridge.rs
@@ -1,4 +1,5 @@
#![cfg(feature = "io-util")]
#![cfg(not(target_os = "wasi"))] // Wasi doesn't support threads

use std::error::Error;
use std::io::{Cursor, Read, Result as IoResult};
Expand Down
2 changes: 1 addition & 1 deletion tokio-util/tests/panic.rs
@@ -1,5 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(feature = "full")]
#![cfg(all(feature = "full", not(target_os = "wasi")))] // Wasi doesn't support panic recovery

use parking_lot::{const_mutex, Mutex};
use std::error::Error;
Expand Down
1 change: 1 addition & 0 deletions tokio-util/tests/spawn_pinned.rs
@@ -1,4 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(not(target_os = "wasi"))] // Wasi doesn't support threads

use std::rc::Rc;
use std::sync::Arc;
Expand Down
14 changes: 7 additions & 7 deletions tokio-util/tests/sync_cancellation_token.rs
Expand Up @@ -258,7 +258,7 @@ fn cancel_only_all_descendants() {
let child2_token = token.child_token();
let grandchild_token = child1_token.child_token();
let grandchild2_token = child1_token.child_token();
let grandgrandchild_token = grandchild_token.child_token();
let great_grandchild_token = grandchild_token.child_token();

assert!(!parent_token.is_cancelled());
assert!(!token.is_cancelled());
Expand All @@ -267,7 +267,7 @@ fn cancel_only_all_descendants() {
assert!(!child2_token.is_cancelled());
assert!(!grandchild_token.is_cancelled());
assert!(!grandchild2_token.is_cancelled());
assert!(!grandgrandchild_token.is_cancelled());
assert!(!great_grandchild_token.is_cancelled());

let parent_fut = parent_token.cancelled();
let fut = token.cancelled();
Expand All @@ -276,7 +276,7 @@ fn cancel_only_all_descendants() {
let child2_fut = child2_token.cancelled();
let grandchild_fut = grandchild_token.cancelled();
let grandchild2_fut = grandchild2_token.cancelled();
let grandgrandchild_fut = grandgrandchild_token.cancelled();
let great_grandchild_fut = great_grandchild_token.cancelled();

pin!(parent_fut);
pin!(fut);
Expand All @@ -285,7 +285,7 @@ fn cancel_only_all_descendants() {
pin!(child2_fut);
pin!(grandchild_fut);
pin!(grandchild2_fut);
pin!(grandgrandchild_fut);
pin!(great_grandchild_fut);

assert_eq!(
Poll::Pending,
Expand Down Expand Up @@ -321,7 +321,7 @@ fn cancel_only_all_descendants() {
);
assert_eq!(
Poll::Pending,
grandgrandchild_fut
great_grandchild_fut
.as_mut()
.poll(&mut Context::from_waker(&waker))
);
Expand All @@ -339,7 +339,7 @@ fn cancel_only_all_descendants() {
assert!(child2_token.is_cancelled());
assert!(grandchild_token.is_cancelled());
assert!(grandchild2_token.is_cancelled());
assert!(grandgrandchild_token.is_cancelled());
assert!(great_grandchild_token.is_cancelled());

assert_eq!(
Poll::Ready(()),
Expand Down Expand Up @@ -367,7 +367,7 @@ fn cancel_only_all_descendants() {
);
assert_eq!(
Poll::Ready(()),
grandgrandchild_fut
great_grandchild_fut
.as_mut()
.poll(&mut Context::from_waker(&waker))
);
Expand Down
2 changes: 2 additions & 0 deletions tokio-util/tests/time_delay_queue.rs
Expand Up @@ -778,6 +778,7 @@ async fn compact_change_deadline() {
assert!(entry.is_none());
}

#[cfg_attr(target_os = "wasi", ignore = "FIXME: Does not seem to work with WASI")]
#[tokio::test(start_paused = true)]
async fn remove_after_compact() {
let now = Instant::now();
Expand All @@ -794,6 +795,7 @@ async fn remove_after_compact() {
assert!(panic.is_err());
}

#[cfg_attr(target_os = "wasi", ignore = "FIXME: Does not seem to work with WASI")]
#[tokio::test(start_paused = true)]
async fn remove_after_compact_poll() {
let now = Instant::now();
Expand Down
1 change: 1 addition & 0 deletions tokio-util/tests/udp.rs
@@ -1,4 +1,5 @@
#![warn(rust_2018_idioms)]
#![cfg(not(target_os = "wasi"))] // Wasi doesn't support UDP

use tokio::net::UdpSocket;
use tokio_stream::StreamExt;
Expand Down

0 comments on commit 0906351

Please sign in to comment.