Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
merged 4 commits into from
Mar 1, 2023
Merged

Conversation

maxbachmann
Copy link
Contributor

@maxbachmann maxbachmann commented Feb 28, 2023

This pulls out the part of #102256 cleaning up old Windows 7 specific code to simplify the review of this PR.

@maxbachmann maxbachmann changed the title gh 102336: remove windows 7 special handling gh-102336: remove windows 7 special handling Feb 28, 2023
@maxbachmann
Copy link
Contributor Author

Does something like this need / should have a news entry?

Comment on lines 6181 to 6186

if (!SetHandleInformation((HANDLE)newfd, HANDLE_FLAG_INHERIT, 0)) {
closesocket(newfd);
PyErr_SetFromWindowsErr(0);
return NULL;
}
Copy link
Contributor Author

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.

Copy link
Contributor

@eryksun eryksun Feb 28, 2023

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.

Copy link
Contributor

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.

@eryksun eryksun requested a review from a team February 28, 2023 23:39
@zooba
Copy link
Member

zooba commented Mar 1, 2023

Does something like this need / should have a news entry?

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.

@zooba zooba self-assigned this Mar 1, 2023
@maxbachmann
Copy link
Contributor Author

Yes from my side this can be merged.

@zooba zooba merged commit 938e36f into python:main Mar 1, 2023
@zooba
Copy link
Member

zooba commented Mar 1, 2023

Thanks for the quick response!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants