From 699573d550fabf4bfb45d82505d6709faaae9037 Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Tue, 3 Jan 2023 12:06:04 -0800 Subject: [PATCH 1/5] net: fix named pipes server configuration builder The `pipe_mode` function would erase any previously set configuration option that is specified using the pipe_mode fit field. This patch fixes the builder to maintain the bit field when changing the pipe mode. --- .github/workflows/ci.yml | 17 --------- tokio/src/net/windows/named_pipe.rs | 54 ++++++++++++++++++++++++++--- 2 files changed, 49 insertions(+), 22 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8b67a0dd17d..ae99b17b7e0 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -33,7 +33,6 @@ jobs: - features - minrust - fmt - - clippy - docs - valgrind - loom-compile @@ -341,22 +340,6 @@ jobs: exit 1 fi - clippy: - name: clippy - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - name: Install Rust ${{ env.rust_clippy }} - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ env.rust_clippy }} - override: true - components: clippy - - uses: Swatinem/rust-cache@v1 - # Run clippy - - name: "clippy --all" - run: cargo clippy --all --tests --all-features - docs: name: docs runs-on: ubuntu-latest diff --git a/tokio/src/net/windows/named_pipe.rs b/tokio/src/net/windows/named_pipe.rs index 695b8eb3d39..51c625e8db6 100644 --- a/tokio/src/net/windows/named_pipe.rs +++ b/tokio/src/net/windows/named_pipe.rs @@ -1681,11 +1681,10 @@ impl ServerOptions { /// /// [`dwPipeMode`]: https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-createnamedpipea pub fn pipe_mode(&mut self, pipe_mode: PipeMode) -> &mut Self { - self.pipe_mode = match pipe_mode { - PipeMode::Byte => winbase::PIPE_TYPE_BYTE, - PipeMode::Message => winbase::PIPE_TYPE_MESSAGE, - }; - + let is_msg = matches!(pipe_mode, PipeMode::Message); + // Pipe mode is implemented as a bit flag 0x4. Set is message and unset + // is byte. + bool_flag!(self.pipe_mode, is_msg, winbase::PIPE_TYPE_MESSAGE); self } @@ -2412,3 +2411,48 @@ unsafe fn named_pipe_info(handle: RawHandle) -> io::Result { max_instances, }) } + +#[cfg(test)] +mod test { + use self::winbase::{PIPE_REJECT_REMOTE_CLIENTS, PIPE_TYPE_BYTE, PIPE_TYPE_MESSAGE}; + use super::*; + + #[test] + fn opts_default_pipe_mode() { + let opts = ServerOptions::new(); + assert_eq!(opts.pipe_mode, PIPE_TYPE_BYTE | PIPE_REJECT_REMOTE_CLIENTS); + } + + #[test] + fn opts_unset_reject_remote() { + let mut opts = ServerOptions::new(); + opts.reject_remote_clients(false); + assert_eq!(opts.pipe_mode & PIPE_REJECT_REMOTE_CLIENTS, 0); + } + + #[test] + fn opts_set_pipe_mode_maintains_reject_remote_clients() { + let mut opts = ServerOptions::new(); + opts.pipe_mode(PipeMode::Byte); + assert_eq!(opts.pipe_mode, PIPE_TYPE_BYTE | PIPE_REJECT_REMOTE_CLIENTS); + + opts.reject_remote_clients(false); + opts.pipe_mode(PipeMode::Byte); + assert_eq!(opts.pipe_mode, PIPE_TYPE_BYTE); + + opts.reject_remote_clients(true); + opts.pipe_mode(PipeMode::Byte); + assert_eq!(opts.pipe_mode, PIPE_TYPE_BYTE | PIPE_REJECT_REMOTE_CLIENTS); + + opts.reject_remote_clients(false); + opts.pipe_mode(PipeMode::Message); + assert_eq!(opts.pipe_mode, PIPE_TYPE_MESSAGE); + + opts.reject_remote_clients(true); + opts.pipe_mode(PipeMode::Message); + assert_eq!( + opts.pipe_mode, + PIPE_TYPE_MESSAGE | PIPE_REJECT_REMOTE_CLIENTS + ); + } +} From 9241c3eddf4a6a218681b088d71f7191513e2376 Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Tue, 3 Jan 2023 12:34:56 -0800 Subject: [PATCH 2/5] chore: prepare Tokio v1.18.4 release --- README.md | 2 +- tokio/CHANGELOG.md | 9 +++++++++ tokio/Cargo.toml | 2 +- tokio/README.md | 2 +- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 81529078ab3..0ef20ec0b18 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ Make sure you activated the full features of the tokio crate on Cargo.toml: ```toml [dependencies] -tokio = { version = "1.18.3", features = ["full"] } +tokio = { version = "1.18.4", features = ["full"] } ``` Then, on your main.rs: diff --git a/tokio/CHANGELOG.md b/tokio/CHANGELOG.md index 7c4076eed2c..8652e4a0e49 100644 --- a/tokio/CHANGELOG.md +++ b/tokio/CHANGELOG.md @@ -1,3 +1,12 @@ +# 1.18.4 (January 3, 2022) + +### Fixed + +- net: fix Windows named pipe server builder to maintain option when toggling + pipe mode ([#5336]). + +[#5336]: https://github.com/tokio-rs/tokio/pull/5336 + # 1.18.3 (September 27, 2022) This release removes the dependency on the `once_cell` crate to restore the MSRV diff --git a/tokio/Cargo.toml b/tokio/Cargo.toml index cf1c2094cc8..42beeb73d64 100644 --- a/tokio/Cargo.toml +++ b/tokio/Cargo.toml @@ -6,7 +6,7 @@ name = "tokio" # - README.md # - Update CHANGELOG.md. # - Create "v1.0.x" git tag. -version = "1.18.3" +version = "1.18.4" edition = "2018" rust-version = "1.49" authors = ["Tokio Contributors "] diff --git a/tokio/README.md b/tokio/README.md index 81529078ab3..0ef20ec0b18 100644 --- a/tokio/README.md +++ b/tokio/README.md @@ -56,7 +56,7 @@ Make sure you activated the full features of the tokio crate on Cargo.toml: ```toml [dependencies] -tokio = { version = "1.18.3", features = ["full"] } +tokio = { version = "1.18.4", features = ["full"] } ``` Then, on your main.rs: From 763bdc967e3e128d1e6e000238f1d257a81bf59a Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Tue, 3 Jan 2023 13:27:58 -0800 Subject: [PATCH 3/5] ci: run WASI tasks using latest Rust This should let CI to pass. --- .github/workflows/ci.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7454732ac59..fe1a56c4771 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -453,10 +453,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 - - name: Install Rust ${{ env.rust_stable }} + - name: Install Rust stable uses: actions-rs/toolchain@v1 with: - toolchain: ${{ env.rust_stable }} + toolchain: stable override: true - uses: Swatinem/rust-cache@v1 @@ -481,3 +481,5 @@ jobs: # TODO: this should become: `cargo hack wasi test --each-feature` run: cargo wasi test --test rt_yield --features wasi-rt working-directory: tests-integration + env: + RUSTFLAGS: "" From ba81945ffc2695b71f2bbcadbfb5e46ec55aaef3 Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Tue, 3 Jan 2023 13:15:13 -0800 Subject: [PATCH 4/5] chore: prepare Tokio 1.20.3 release --- README.md | 2 +- tokio/CHANGELOG.md | 11 +++++++++++ tokio/Cargo.toml | 2 +- tokio/README.md | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4fb3abe9f8c..3113fadd8ab 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ Make sure you activated the full features of the tokio crate on Cargo.toml: ```toml [dependencies] -tokio = { version = "1.20.2", features = ["full"] } +tokio = { version = "1.20.3", features = ["full"] } ``` Then, on your main.rs: diff --git a/tokio/CHANGELOG.md b/tokio/CHANGELOG.md index 6f0c07d7b10..42d1f6b8f2a 100644 --- a/tokio/CHANGELOG.md +++ b/tokio/CHANGELOG.md @@ -1,3 +1,14 @@ +# 1.20.3 (January 3, 2022) + +This release forward ports changes from 1.18.4. + +### Fixed + +- net: fix Windows named pipe server builder to maintain option when toggling + pipe mode ([#5336]). + +[#5336]: https://github.com/tokio-rs/tokio/pull/5336 + # 1.20.2 (September 27, 2022) This release removes the dependency on the `once_cell` crate to restore the MSRV diff --git a/tokio/Cargo.toml b/tokio/Cargo.toml index 0dc0de79ce0..a83937445b6 100644 --- a/tokio/Cargo.toml +++ b/tokio/Cargo.toml @@ -6,7 +6,7 @@ name = "tokio" # - README.md # - Update CHANGELOG.md. # - Create "v1.0.x" git tag. -version = "1.20.2" +version = "1.20.3" edition = "2018" rust-version = "1.49" authors = ["Tokio Contributors "] diff --git a/tokio/README.md b/tokio/README.md index 4fb3abe9f8c..3113fadd8ab 100644 --- a/tokio/README.md +++ b/tokio/README.md @@ -56,7 +56,7 @@ Make sure you activated the full features of the tokio crate on Cargo.toml: ```toml [dependencies] -tokio = { version = "1.20.2", features = ["full"] } +tokio = { version = "1.20.3", features = ["full"] } ``` Then, on your main.rs: From 1a997ffbd62334af2553775234e75ede2d7d949f Mon Sep 17 00:00:00 2001 From: Carl Lerche Date: Wed, 4 Jan 2023 10:32:38 -0800 Subject: [PATCH 5/5] chore: prepare Tokio v1.23.1 release --- README.md | 2 +- tokio/CHANGELOG.md | 11 +++++++++++ tokio/Cargo.toml | 2 +- tokio/README.md | 2 +- 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 3e51cf546b7..67d931d1a8d 100644 --- a/README.md +++ b/README.md @@ -56,7 +56,7 @@ Make sure you activated the full features of the tokio crate on Cargo.toml: ```toml [dependencies] -tokio = { version = "1.23.0", features = ["full"] } +tokio = { version = "1.23.1", features = ["full"] } ``` Then, on your main.rs: diff --git a/tokio/CHANGELOG.md b/tokio/CHANGELOG.md index 80835dc1e1e..0f1ad8bc61a 100644 --- a/tokio/CHANGELOG.md +++ b/tokio/CHANGELOG.md @@ -1,3 +1,14 @@ +# 1.23.1 (January 4, 2022) + +This release forward ports changes from 1.18.4. + +### Fixed + +- net: fix Windows named pipe server builder to maintain option when toggling + pipe mode ([#5336]). + +[#5336]: https://github.com/tokio-rs/tokio/pull/5336 + # 1.23.0 (December 5, 2022) ### Fixed diff --git a/tokio/Cargo.toml b/tokio/Cargo.toml index 78cba811156..4dd60339863 100644 --- a/tokio/Cargo.toml +++ b/tokio/Cargo.toml @@ -6,7 +6,7 @@ name = "tokio" # - README.md # - Update CHANGELOG.md. # - Create "v1.x.y" git tag. -version = "1.23.0" +version = "1.23.1" edition = "2018" rust-version = "1.49" authors = ["Tokio Contributors "] diff --git a/tokio/README.md b/tokio/README.md index 3e51cf546b7..67d931d1a8d 100644 --- a/tokio/README.md +++ b/tokio/README.md @@ -56,7 +56,7 @@ Make sure you activated the full features of the tokio crate on Cargo.toml: ```toml [dependencies] -tokio = { version = "1.23.0", features = ["full"] } +tokio = { version = "1.23.1", features = ["full"] } ``` Then, on your main.rs: