Skip to content

Commit a8fe333

Browse files
committed
Merge branch 'tokio-1.20.x' into tokio-1.23.x
2 parents 3ce5a26 + ba81945 commit a8fe333

File tree

2 files changed

+69
-5
lines changed

2 files changed

+69
-5
lines changed

tokio/CHANGELOG.md

+20
Original file line numberDiff line numberDiff line change
@@ -262,6 +262,17 @@ wasm32-wasi target is given unstable support for the `net` feature.
262262
[#4956]: https://github.com/tokio-rs/tokio/pull/4956
263263
[#4959]: https://github.com/tokio-rs/tokio/pull/4959
264264

265+
# 1.20.3 (January 3, 2022)
266+
267+
This release forward ports changes from 1.18.4.
268+
269+
### Fixed
270+
271+
- net: fix Windows named pipe server builder to maintain option when toggling
272+
pipe mode ([#5336]).
273+
274+
[#5336]: https://github.com/tokio-rs/tokio/pull/5336
275+
265276
# 1.20.2 (September 27, 2022)
266277

267278
This release removes the dependency on the `once_cell` crate to restore the MSRV
@@ -387,6 +398,15 @@ This release fixes a bug in `Notified::enable`. ([#4747])
387398
[#4729]: https://github.com/tokio-rs/tokio/pull/4729
388399
[#4739]: https://github.com/tokio-rs/tokio/pull/4739
389400

401+
# 1.18.4 (January 3, 2022)
402+
403+
### Fixed
404+
405+
- net: fix Windows named pipe server builder to maintain option when toggling
406+
pipe mode ([#5336]).
407+
408+
[#5336]: https://github.com/tokio-rs/tokio/pull/5336
409+
390410
# 1.18.3 (September 27, 2022)
391411

392412
This release removes the dependency on the `once_cell` crate to restore the MSRV

tokio/src/net/windows/named_pipe.rs

+49-5
Original file line numberDiff line numberDiff line change
@@ -1705,11 +1705,10 @@ impl ServerOptions {
17051705
///
17061706
/// [`dwPipeMode`]: https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-createnamedpipea
17071707
pub fn pipe_mode(&mut self, pipe_mode: PipeMode) -> &mut Self {
1708-
self.pipe_mode = match pipe_mode {
1709-
PipeMode::Byte => windows_sys::PIPE_TYPE_BYTE,
1710-
PipeMode::Message => windows_sys::PIPE_TYPE_MESSAGE,
1711-
};
1712-
1708+
let is_msg = matches!(pipe_mode, PipeMode::Message);
1709+
// Pipe mode is implemented as a bit flag 0x4. Set is message and unset
1710+
// is byte.
1711+
bool_flag!(self.pipe_mode, is_msg, windows_sys::PIPE_TYPE_MESSAGE);
17131712
self
17141713
}
17151714

@@ -2554,3 +2553,48 @@ unsafe fn named_pipe_info(handle: RawHandle) -> io::Result<PipeInfo> {
25542553
max_instances,
25552554
})
25562555
}
2556+
2557+
#[cfg(test)]
2558+
mod test {
2559+
use self::windows_sys::{PIPE_REJECT_REMOTE_CLIENTS, PIPE_TYPE_BYTE, PIPE_TYPE_MESSAGE};
2560+
use super::*;
2561+
2562+
#[test]
2563+
fn opts_default_pipe_mode() {
2564+
let opts = ServerOptions::new();
2565+
assert_eq!(opts.pipe_mode, PIPE_TYPE_BYTE | PIPE_REJECT_REMOTE_CLIENTS);
2566+
}
2567+
2568+
#[test]
2569+
fn opts_unset_reject_remote() {
2570+
let mut opts = ServerOptions::new();
2571+
opts.reject_remote_clients(false);
2572+
assert_eq!(opts.pipe_mode & PIPE_REJECT_REMOTE_CLIENTS, 0);
2573+
}
2574+
2575+
#[test]
2576+
fn opts_set_pipe_mode_maintains_reject_remote_clients() {
2577+
let mut opts = ServerOptions::new();
2578+
opts.pipe_mode(PipeMode::Byte);
2579+
assert_eq!(opts.pipe_mode, PIPE_TYPE_BYTE | PIPE_REJECT_REMOTE_CLIENTS);
2580+
2581+
opts.reject_remote_clients(false);
2582+
opts.pipe_mode(PipeMode::Byte);
2583+
assert_eq!(opts.pipe_mode, PIPE_TYPE_BYTE);
2584+
2585+
opts.reject_remote_clients(true);
2586+
opts.pipe_mode(PipeMode::Byte);
2587+
assert_eq!(opts.pipe_mode, PIPE_TYPE_BYTE | PIPE_REJECT_REMOTE_CLIENTS);
2588+
2589+
opts.reject_remote_clients(false);
2590+
opts.pipe_mode(PipeMode::Message);
2591+
assert_eq!(opts.pipe_mode, PIPE_TYPE_MESSAGE);
2592+
2593+
opts.reject_remote_clients(true);
2594+
opts.pipe_mode(PipeMode::Message);
2595+
assert_eq!(
2596+
opts.pipe_mode,
2597+
PIPE_TYPE_MESSAGE | PIPE_REJECT_REMOTE_CLIENTS
2598+
);
2599+
}
2600+
}

0 commit comments

Comments
 (0)