-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
gh-102336: remove windows 7 special handling #102337
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
Conversation
Does something like this need / should have a news entry? |
Modules/socketmodule.c
Outdated
|
||
if (!SetHandleInformation((HANDLE)newfd, HANDLE_FLAG_INHERIT, 0)) { | ||
closesocket(newfd); | ||
PyErr_SetFromWindowsErr(0); | ||
return NULL; | ||
} |
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.
@eryksun are you sure this is the correct change? This seems to break the tests.
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.
Sorry. I forgot that the WSASocketW()
call in this case isn't responsible for duplicating the handle into the current process. It's implemented the other way around. The API can't assume that the process that calls WSASocketW()
is allowed to duplicate a handle from the process that calls WSADuplicateSocketW()
. Instead the value of the already duplicated handle is passed in the WSAPROTOCOL_INFOW
record. This handle is inheritable, so calling SetHandleInformation()
is required in this case.
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.
Calling SetHandleInformation()
is thus also required in sock_initobj_impl()
for the case where a socket is created with FROM_PROTOCOL_INFO
. I'd do the SetHandleInformation()
call locally right after calling WSASocketW()
, and add a comment that explains why WSA_FLAG_NO_HANDLE_INHERIT
doesn't work.
The other WSASocketW()
call in sock_initobj_impl()
doesn't need SetHandleInformation()
. Keeping it separate and adding a comment makes it less likely that we'll mistakenly go down this path again.
Yeah, I think it should. But it's got one now. The change looks good to me overall, and passes CI. If you think it's ready, I'll go ahead and merge, or let me know if you want to hold off for a bit. |
Yes from my side this can be merged. |
Thanks for the quick response! |
This pulls out the part of #102256 cleaning up old Windows 7 specific code to simplify the review of this PR.