Skip to content

Commit

Permalink
wip: fix CreateIoCompletionPort usage on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
passcod committed Mar 11, 2024
1 parent b928d6a commit b5b4bea
Show file tree
Hide file tree
Showing 4 changed files with 2 additions and 172 deletions.
151 changes: 0 additions & 151 deletions Cargo.lock

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

4 changes: 0 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ edition = "2021"
exclude = ["/bin", "/.github"]
rust-version = "1.75.0"

# there are a few windows-specific ones
autoexamples = false

[dependencies]
futures = "0.3.30"
indexmap = "2.2.5"
Expand All @@ -33,7 +30,6 @@ windows = { version = "0.53.0", optional = true }

[dev-dependencies]
tokio = { version = "1.33.0", features = ["io-util", "macros", "process", "rt", "rt-multi-thread", "time"] }
tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }

[features]
default = ["creation-flags", "job-object", "process-group", "process-session"]
Expand Down
4 changes: 2 additions & 2 deletions src/windows.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use std::{

use tracing::{debug, instrument};
use windows::Win32::{
Foundation::{CloseHandle, HANDLE},
Foundation::{CloseHandle, HANDLE, INVALID_HANDLE_VALUE},
System::{
Diagnostics::ToolHelp::{
CreateToolhelp32Snapshot, Thread32First, Thread32Next, TH32CS_SNAPTHREAD, THREADENTRY32,
Expand Down Expand Up @@ -52,7 +52,7 @@ pub(crate) fn make_job_object(handle: HANDLE, kill_on_drop: bool) -> Result<JobP
let job = unsafe { CreateJobObjectW(None, None) }.map_err(Error::other)?;
debug!(?job, "done CreateJobObjectW");

let completion_port = unsafe { CreateIoCompletionPort(None, None, 0, 1) }?;
let completion_port = unsafe { CreateIoCompletionPort(INVALID_HANDLE_VALUE, None, 0, 1) }?;
debug!(?completion_port, "done CreateIoCompletionPort");

let associate_completion = JOBOBJECT_ASSOCIATE_COMPLETION_PORT {
Expand Down
15 changes: 0 additions & 15 deletions tests/tokio_windows/id_same_as_inner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,6 @@ async fn nowrap() -> Result<()> {

#[tokio::test]
async fn job_object() -> Result<()> {
tracing_subscriber::fmt::fmt()
.pretty()
.with_env_filter(tracing_subscriber::filter::EnvFilter::from_default_env())
.with_span_events(tracing_subscriber::fmt::format::FmtSpan::FULL)
.init();
let child = TokioCommandWrap::with_new("powershell.exe", |command| {
command.arg("/C").arg("echo hello").stdout(Stdio::null());
})
Expand All @@ -29,13 +24,3 @@ async fn job_object() -> Result<()> {

Ok(())
}

#[tokio::test]
async fn job_object_spawn_only() -> Result<()> {
TokioCommandWrap::with_new("powershell.exe", |command| {
command.arg("/C").arg("echo hello").stdout(Stdio::null());
})
.wrap(JobObject)
.spawn()?;
Ok(())
}

0 comments on commit b5b4bea

Please sign in to comment.