Skip to content

Commit

Permalink
Showing 7 changed files with 309 additions and 81 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ jobs:
resource_class: arm.medium
environment:
# Change to pin rust version
RUST_STABLE: stable
RUST_STABLE: 1.67.1
steps:
- checkout
- run:
15 changes: 7 additions & 8 deletions .cirrus.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
only_if: $CIRRUS_TAG == '' && ($CIRRUS_PR != '' || $CIRRUS_BRANCH == 'master' || $CIRRUS_BRANCH =~ 'tokio-.*')
auto_cancellation: $CIRRUS_BRANCH != 'master' && $CIRRUS_BRANCH !=~ 'tokio-.*'
freebsd_instance:
image: freebsd-12-4-release-amd64
image_family: freebsd-13-1
env:
RUST_STABLE: stable
RUST_STABLE: 1.67.1
RUST_NIGHTLY: nightly-2022-10-25
RUSTFLAGS: -D warnings

@@ -11,9 +13,8 @@ env:
# the system's binaries, so the environment shouldn't matter.
task:
name: FreeBSD 64-bit
auto_cancellation: $CIRRUS_BRANCH != 'master' && $CIRRUS_BRANCH !=~ 'tokio-.*'
setup_script:
- pkg install -y bash curl
- pkg install -y bash
- curl https://sh.rustup.rs -sSf --output rustup.sh
- sh rustup.sh -y --profile minimal --default-toolchain $RUST_STABLE
- . $HOME/.cargo/env
@@ -26,12 +27,11 @@ task:

task:
name: FreeBSD docs
auto_cancellation: $CIRRUS_BRANCH != 'master' && $CIRRUS_BRANCH !=~ 'tokio-.*'
env:
RUSTFLAGS: --cfg docsrs --cfg tokio_unstable
RUSTDOCFLAGS: --cfg docsrs --cfg tokio_unstable -Dwarnings
setup_script:
- pkg install -y bash curl
- pkg install -y bash
- curl https://sh.rustup.rs -sSf --output rustup.sh
- sh rustup.sh -y --profile minimal --default-toolchain $RUST_NIGHTLY
- . $HOME/.cargo/env
@@ -44,9 +44,8 @@ task:

task:
name: FreeBSD 32-bit
auto_cancellation: $CIRRUS_BRANCH != 'master' && $CIRRUS_BRANCH !=~ 'tokio-.*'
setup_script:
- pkg install -y bash curl
- pkg install -y bash
- curl https://sh.rustup.rs -sSf --output rustup.sh
- sh rustup.sh -y --profile minimal --default-toolchain $RUST_STABLE
- . $HOME/.cargo/env
15 changes: 1 addition & 14 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ env:
RUSTFLAGS: -Dwarnings
RUST_BACKTRACE: 1
# Change to specific Rust release to pin
rust_stable: stable
rust_stable: 1.67.1
rust_nightly: nightly-2022-11-03
rust_clippy: 1.65.0
# When updating this, also update:
@@ -349,19 +349,6 @@ jobs:
with:
toolchain: ${{ env.rust_min }}
- uses: Swatinem/rust-cache@v2
# First compile just the main tokio crate with minrust and newest version
# of all dependencies, then pin once_cell and compile the rest of the
# crates with the pinned once_cell version.
#
# This is necessary because tokio-util transitively depends on once_cell,
# which is not compatible with the current minrust after the 1.15.0
# release.
- name: "check -p tokio --all-features"
run: cargo check -p tokio --all-features
env:
RUSTFLAGS: "" # remove -Dwarnings
- name: "pin once_cell version"
run: cargo update -p once_cell --precise 1.14.0
- name: "check --workspace --all-features"
run: cargo check --workspace --all-features
env:
291 changes: 291 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions tokio-util/tests/time_delay_queue.rs
Original file line number Diff line number Diff line change
@@ -257,6 +257,10 @@ async fn reset_twice() {
#[tokio::test]
async fn repeatedly_reset_entry_inserted_as_expired() {
time::pause();

// Instants before the start of the test seem to break in wasm.
time::sleep(ms(1000)).await;

let mut queue = task::spawn(DelayQueue::new());
let now = Instant::now();

@@ -556,6 +560,10 @@ async fn reset_later_after_slot_starts() {
#[tokio::test]
async fn reset_inserted_expired() {
time::pause();

// Instants before the start of the test seem to break in wasm.
time::sleep(ms(1000)).await;

let mut queue = task::spawn(DelayQueue::new());
let now = Instant::now();

3 changes: 0 additions & 3 deletions tokio/Cargo.toml
Original file line number Diff line number Diff line change
@@ -135,9 +135,6 @@ features = [
"Win32_Security_Authorization",
]

[target.'cfg(windows)'.dev-dependencies.ntapi]
version = "0.3.6"

[dev-dependencies]
tokio-test = { version = "0.4.0", path = "../tokio-test" }
tokio-stream = { version = "0.1", path = "../tokio-stream" }
56 changes: 1 addition & 55 deletions tokio/tests/net_named_pipe.rs
Original file line number Diff line number Diff line change
@@ -2,22 +2,18 @@
#![cfg(all(windows))]

use std::io;
use std::mem;
use std::os::windows::io::AsRawHandle;
use std::time::Duration;
use tokio::io::AsyncWriteExt;
use tokio::net::windows::named_pipe::{ClientOptions, PipeMode, ServerOptions};
use tokio::time;
use windows_sys::Win32::Foundation::{ERROR_NO_DATA, ERROR_PIPE_BUSY, NO_ERROR, UNICODE_STRING};
use windows_sys::Win32::Foundation::{ERROR_NO_DATA, ERROR_PIPE_BUSY};

#[tokio::test]
async fn test_named_pipe_client_drop() -> io::Result<()> {
const PIPE_NAME: &str = r"\\.\pipe\test-named-pipe-client-drop";

let mut server = ServerOptions::new().create(PIPE_NAME)?;

assert_eq!(num_instances("test-named-pipe-client-drop")?, 1);

let client = ClientOptions::new().open(PIPE_NAME)?;

server.connect().await?;
@@ -367,53 +363,3 @@ async fn test_named_pipe_access() -> io::Result<()> {
}
Ok(())
}

fn num_instances(pipe_name: impl AsRef<str>) -> io::Result<u32> {
use ntapi::ntioapi;

let mut name = pipe_name.as_ref().encode_utf16().collect::<Vec<_>>();
let mut name = UNICODE_STRING {
Length: (name.len() * mem::size_of::<u16>()) as u16,
MaximumLength: (name.len() * mem::size_of::<u16>()) as u16,
Buffer: name.as_mut_ptr(),
};
let root = std::fs::File::open(r"\\.\Pipe\")?;
let mut io_status_block = unsafe { mem::zeroed() };
let mut file_directory_information = [0_u8; 1024];

let status = unsafe {
ntioapi::NtQueryDirectoryFile(
root.as_raw_handle(),
std::ptr::null_mut(),
None,
std::ptr::null_mut(),
&mut io_status_block,
&mut file_directory_information as *mut _ as *mut _,
1024,
ntioapi::FileDirectoryInformation,
0,
&mut name as *mut _ as _,
0,
)
};

if status as u32 != NO_ERROR {
return Err(io::Error::last_os_error());
}

let info = unsafe {
mem::transmute::<_, &ntioapi::FILE_DIRECTORY_INFORMATION>(&file_directory_information)
};
let raw_name = unsafe {
std::slice::from_raw_parts(
info.FileName.as_ptr(),
info.FileNameLength as usize / mem::size_of::<u16>(),
)
};
let name = String::from_utf16(raw_name).unwrap();
let num_instances = unsafe { *info.EndOfFile.QuadPart() };

assert_eq!(name, pipe_name.as_ref());

Ok(num_instances as u32)
}

0 comments on commit 4b032a2

Please sign in to comment.