-
Notifications
You must be signed in to change notification settings - Fork 13.9k
std::os::windows::net: add Unix-domain socket support (AF_UNIX on Windows) #147335
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
base: master
Are you sure you want to change the base?
Conversation
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
☔ The latest upstream changes (presumably #147340) made this pull request unmergeable. Please resolve the merge conflicts. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
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.
Thanks!
library/std/Cargo.toml
Outdated
| # This will eventually be the default. | ||
| windows_raw_dylib = ["windows-targets/windows_raw_dylib"] | ||
|
|
||
| windows_unix_domain_sockets = [] |
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.
This is unneeded unless something in the standard library is going to be doing cfg(feature = "windows_unix_domain_sockets"). Standard library nightly features feature(windows_unix_domain_sockets) are not supposed to be listed in this file.
library/std/src/os/windows/mod.rs
Outdated
| #[cfg(windows)] | ||
| pub mod net; |
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.
The std::windows module does something unusual with cfg(doc) to render omnibus documentation that includes all platform-specific APIs from mutually exclusive platforms (e.g. windows-specific and unix-specific in the same documentation build). See library/std/src/os/mod.rs and https://doc.rust-lang.org/1.91.0/std/os/windows/index.html.
By putting cfg(windows) here, none of this will appear in rendered standard library documentation.
Please look into how the other contents of std::windows use cfg and follow the same approach. If that is not possible, please document this line explaining why it is done differently.
| @@ -0,0 +1,8 @@ | |||
| #![unstable(feature = "windows_unix_domain_sockets", issue = "56533")] | |||
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.
most of the code was transplanted from https://github.com/Azure/mio-uds-windows
I am not sure that's going to be allowed. The mio-uds-windows repo is MIT licensed only whereas the standard library is dual licensed.
Lines 17 to 19 in 20383c9
| Except as otherwise noted, Rust is licensed under the Apache License, Version | |
| 2.0 <LICENSE-APACHE> or <http://www.apache.org/licenses/LICENSE-2.0> or the MIT | |
| license <LICENSE-MIT> or <http://opensource.org/licenses/MIT>, at your option. |
We cannot legally take MIT-only code and unilaterally relicense it to Apache 2.0. One of the following needs to happen:
-
The upstream code needs to be relicensed.
-
The upstream copyright holder needs to grant Rust the right to take the code under a different license.
-
The actual license of the domain socket code for Windows needs to be explained in the standard library source code sufficiently clearly to fall under "as otherwise noted".
-
The contribution needs to be rewritten by somebody else without reference to copyrighted material from the original implementation.
This comment has been minimized.
This comment has been minimized.
|
Hi @damonbarry, I'm currently working on adding Unix Domain Socket support for Windows to the Rust standard library. My implementation is based on your mio-uds-windows repository, but I've adapted it to use Rust's standard Windows bindings instead of windows-rs. I've submitted a PR to the Rust repository, and now need to address the licensing compatibility. Your project uses the MIT license, while Rust uses dual MIT/Apache-2.0 licensing. Would you be willing to allow your code to be used in the Rust standard library under the Rust project's dual licensing terms (MIT/Apache-2.0)? This would help ensure the UDS functionality can be properly integrated into std. The changes I made primarily involve replacing the windows-rs dependencies with std's Windows bindings, while maintaining the core logic and structure from your implementation. Please let me know if you're comfortable with this usage. If you have any questions or need more details about the implementation, I'd be happy to provide them. Thank you for your great work on mio-uds-windows! |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
This PR was rebased onto a different master commit. Here's a range-diff highlighting what actually changed. Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Co-authored-by: David Tolnay <[email protected]>
|
The job Click to see the possible cause of the failure (guessed by this bot) |
r? rust-lang/libs-api
Summary
This PR adds Unix-domain socket support to the Windows port of the standard library,
mirroring the existing APIs in
std::os::unix::net.The implementation is gated behind the unstable feature
windows_unix_domain_sockets;track issue #56533 .
Motivation / Background
Windows 10 17063+ officially support AF_UNIX.
Having the same
UnixStream/UnixListenersurface on Windows removes the need forcrates such as
mio-uds-windowsand lets cross-platform code use a single API.Acknowledgements
most of the code was transplanted from
https://github.com/Azure/mio-uds-windows
(thank you @damonbarry ).
The main delta is switching from the
winapicrate to thestd.What is added
std::os::windows::netUnixStream,UnixListener,SocketAddr,sockaddr_unAll types mirror their Unix counterparts and implement the usual
Read+Write,AsRawSocket/FromRawSocket/IntoRawSocket,AsSocket, etc.Feature gate
Testing
Can't run test because rustc ICE
How to try it locally
Notes for reviewers
sys::pal::windows.unsafeis restricted toWSASocketW,bind,connect,getsockname,getpeername.sockaddr_unconstruction follows the Unix implementation: zero-init, copy path, null-term.Dropimpl is reused fromsys::net::Socket, soclosesocketalways runs.Commit message
Checklist before clicking “Create pull request”
./x.py fmt- clean./x.py test- passed