-
Notifications
You must be signed in to change notification settings - Fork 5.7k
feat(unstable): support named pipes on Windows for the permission broker #30894
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(unstable): support named pipes on Windows for the permission broker #30894
Conversation
dsherret
commented
Oct 1, 2025
|
||
#[cfg(windows)] | ||
impl LocalStream { | ||
fn connect_impl(addr: &OsStr) -> io::Result<Self> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AI generated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
AI generated.
// 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); | ||
} | ||
}; |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM!