Skip to content

Conversation

dsherret
Copy link
Member

@dsherret dsherret commented Oct 1, 2025

> $env:DENO_PERMISSION_BROKER_PATH="\\.\pipe\deno-permission-broker" ; deno run script.ts


#[cfg(windows)]
impl LocalStream {
fn connect_impl(addr: &OsStr) -> io::Result<Self> {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI generated.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI generated.

@dsherret dsherret requested a review from nathanwhit October 2, 2025 02:22
Comment on lines +58 to +83
// Try to open; if the pipe is busy, wait and retry.
let handle = loop {
// SAFETY: WinAPI call
let h = unsafe {
CreateFileW(
wide.as_ptr(),
FILE_GENERIC_READ | FILE_GENERIC_WRITE,
0, // no sharing
std::ptr::null(),
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL, // blocking
std::ptr::null_mut(),
)
};
if h != INVALID_HANDLE_VALUE {
break h;
}
let err = io::Error::last_os_error();
if err.raw_os_error() == Some(ERROR_PIPE_BUSY as i32) {
// SAFETY: WinAPI call
unsafe { WaitNamedPipeW(wide.as_ptr(), NMPWAIT_WAIT_FOREVER) };
continue;
} else {
return Err(err);
}
};
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you can just WaitNamedPipeW before CreateFileW and remove the loop.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently this should be left as-is in order to handle race conditions (ex. WaitNamedPipeW succeeds, but then fails for CreateFileW).

Copy link
Member

@nathanwhit nathanwhit left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@dsherret dsherret merged commit 5f308da into denoland:main Oct 2, 2025
32 of 36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants