-
Notifications
You must be signed in to change notification settings - Fork 13.3k
std: Set overlap/noinherit flags on windows sockets #24211
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
std: Set overlap/noinherit flags on windows sockets #24211
Conversation
r? @brson (rust_highfive has picked a reviewer for you, use r? to override) |
Would it be appropriate to extend the docs to indicate that these are on by default? |
Hm I definitely think it would be appropriate! I'm not quite sure where said docs would go though as we don't currently have many platform-specific docs. Would you be ok if I opened a bug in the meantime for this topic? |
@@ -44,6 +44,8 @@ pub const WSA_WAIT_TIMEOUT: libc::DWORD = libc::consts::os::extra::WAIT_TIMEOUT; | |||
pub const WSA_WAIT_EVENT_0: libc::DWORD = libc::consts::os::extra::WAIT_OBJECT_0; | |||
pub const WSA_WAIT_FAILED: libc::DWORD = libc::consts::os::extra::WAIT_FAILED; | |||
pub const WSAESHUTDOWN: libc::c_int = 10058; | |||
pub const WSA_FLAG_OVERLAPPED: libc::DWORD = 0x4; | |||
pub const WSA_FLAG_NO_HANDLE_INHERIT: libc::DWORD = 0x8; |
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.
These are incorrect
#define WSA_FLAG_OVERLAPPED 0x01
#define WSA_FLAG_NO_HANDLE_INHERIT 0x80
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.
Oops, good catch!
This commit modifies the socket creation functions on windows to always specify the `WSA_FLAG_OVERLAPPED` and `WSA_FLAG_NO_HANDLE_INHERIT` flags by default. The overlapped flag enables IOCP APIs on Windows to be used with the socket at no cost, enabling better interoperation with external libraries. The no handle inherit flag mirrors the upcoming change to Unix to set CLOEXEC by default for all handles. Closes rust-lang#24206
9013a57
to
433f0e8
Compare
r? @aturon |
re: docs, I believe we discussed having a "Platform behavior" subsection as part of the IO audit. But yes, this can wait for that sweep. Meanwhile, @bors: r+ |
📌 Commit 433f0e8 has been approved by |
…uron This commit modifies the socket creation functions on windows to always specify the `WSA_FLAG_OVERLAPPED` and `WSA_FLAG_NO_HANDLE_INHERIT` flags by default. The overlapped flag enables IOCP APIs on Windows to be used with the socket at no cost, enabling better interoperation with external libraries. The no handle inherit flag mirrors the upcoming change to Unix to set CLOEXEC by default for all handles. Closes #24206
This commit modifies the socket creation functions on windows to always specify
the
WSA_FLAG_OVERLAPPED
andWSA_FLAG_NO_HANDLE_INHERIT
flags by default. Theoverlapped flag enables IOCP APIs on Windows to be used with the socket at no
cost, enabling better interoperation with external libraries. The no handle
inherit flag mirrors the upcoming change to Unix to set CLOEXEC by default for
all handles.
Closes #24206