Skip to content

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

Merged
merged 1 commit into from
Apr 15, 2015

Conversation

alexcrichton
Copy link
Member

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

@rust-highfive
Copy link
Contributor

r? @brson

(rust_highfive has picked a reviewer for you, use r? to override)

@brson
Copy link
Contributor

brson commented Apr 8, 2015

Would it be appropriate to extend the docs to indicate that these are on by default?

@alexcrichton
Copy link
Member Author

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;
Copy link
Member

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

Copy link
Member Author

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
@alexcrichton alexcrichton force-pushed the windows-wsa-flag-overlapped branch from 9013a57 to 433f0e8 Compare April 14, 2015 18:09
@alexcrichton
Copy link
Member Author

r? @aturon

@rust-highfive rust-highfive assigned aturon and unassigned brson Apr 14, 2015
@aturon
Copy link
Member

aturon commented Apr 15, 2015

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+

@bors
Copy link
Collaborator

bors commented Apr 15, 2015

📌 Commit 433f0e8 has been approved by aturon

bors added a commit that referenced this pull request Apr 15, 2015
…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
@bors
Copy link
Collaborator

bors commented Apr 15, 2015

⌛ Testing commit 433f0e8 with merge af1c39c...

@bors bors merged commit 433f0e8 into rust-lang:master Apr 15, 2015
@alexcrichton alexcrichton deleted the windows-wsa-flag-overlapped branch April 30, 2015 02:13
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.

On windows, initialize IO types (for example, sockets) with WSA_FLAG_OVERLAPPED
6 participants