◐ Shell
reader mode source ↗
Skip to content

bpo-32394: Remove some TCP options on old version Windows.#5523

Merged
zooba merged 20 commits into
masterfrom
unknown repository
Feb 26, 2018
Merged

bpo-32394: Remove some TCP options on old version Windows.#5523
zooba merged 20 commits into
masterfrom
unknown repository

Conversation

@ghost

@ghost ghost commented Feb 4, 2018

Copy link
Copy Markdown

@skn78

skn78 commented Feb 4, 2018

Copy link
Copy Markdown

Microsoft site says "GetVersionEx may be altered or unavailable for releases after Windows 8.1. Instead, use the Version Helper functions"
VersionHelpers.h has "IsWindows10CreatorsOrGreater()" function for checking Windows 10 Build 15063+ and has "IsWindows10AnniversaryOrGreater()" function for checking Windows 10 Build 14393+.
It are official functions.

zware
zware previously requested changes Feb 4, 2018

@zware zware left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hide comment

Agreed with @skn78, this should use functions from VersionHelpers.h, not the deprecated GetVersionEx.

@bedevere-bot

Copy link
Copy Markdown

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@ghost

ghost commented Feb 5, 2018

Copy link
Copy Markdown
Author

Earlier versions of Windows 10 SDK don't have IsWindows10CreatorsOrGreater() function, people will get a build failure with those Win 10 SDK.
I'm thinking a workaround, any ideas?

@ghost

ghost commented Feb 6, 2018

Copy link
Copy Markdown
Author

Offical VersionHelpers.h doesn't have IsWindows10CreatorsOrGreater() and IsWindows10AnniversaryOrGreater() functions.

The two functions are available in a third part VersionHelpers.h, which using a DDK interface RtlGetVersion(...) to get version infomation.

Now I'm inclined to patch in socket.py again, although sys.getwindowsversion() is also using GetVersionEx(...) in underlying level. At least, it keeps socketmodule.c neat.
A code block like this solves the problem:

if hasattr(sys, 'getwindowsversion'):
    # (new_option, available_build)
    # make sure the list ordered by available_build descendent
    _new_flags = [
        ('TCP_KEEPIDLE',  16299),  # Windows 10 1709
        ('TCP_KEEPINTVL', 16299),
        ('TCP_KEEPCNT',   15063),  # Windows 10 1703
        ('TCP_FASTOPEN',  14393)   # Windows 10 1607
        ]
    _WIN_MAJOR, _WIN_MINOR, _WIN_BUILD, *_ = sys.getwindowsversion()
    
    if _WIN_MAJOR == 10 and _WIN_MINOR == 0:
        for _flag, _build in _new_flags:
            if _WIN_BUILD < _build:
                if hasattr(_socket, _flag):
                    delattr(_socket, _flag)
            else:
                break
    elif _WIN_MAJOR < 10:
        for _flag, _ in _new_flags:
            if hasattr(_socket, _flag):
                delattr(_socket, _flag)

@ghost

ghost commented Feb 11, 2018

Copy link
Copy Markdown
Author

This PR is prepared for review.

Official VersionHelpers.h uses VerifyVersionInfo(...) function in the inner side.
I'm also using VerifyVersionInfo(...), but made it aware of BuildNumber.

This PR is conflicts with 3.6 branch code.
PR 5585 is prepared for 3.6 branch, besides code conflict, the only difference is that PR 5585 can't recognize the two flags (TCP_KEEPIDLE,TCP_KEEPINTVL) added in 1709 SDK.

@zware zware dismissed their stale review February 12, 2018 17:10

Comment addressed; not qualified for full review.

@ghost

ghost commented Feb 13, 2018

Copy link
Copy Markdown
Author

@zware
Forgive me for my verdant of GitHub.
This morning I pushed a minor commit, after that, I found there was a message:

zware dismissed their stale review 9 hours ago
Comment addressed; not qualified for full review.

But I can't found any comment, this make me feel very embarrassed.
So if you had addressed a comment, could you please post it again?

@zware

zware commented Feb 13, 2018

Copy link
Copy Markdown
Member

Look just above the message from @bedevere-bot for my old review comment, which was just formalization of the comment left by @skn78 and which you have addressed already.

I'm afraid that's about the extent of my ability to review this one, though.

12 hidden items Load more…
@ghost

ghost commented Feb 14, 2018

Copy link
Copy Markdown
Author

ok

@zooba zooba left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hide comment

There's nothing really wrong here, just a few suggestions and some code-quality items that we really can't let through (I don't think we have linting for them, and we probably can't add it easily at this stage, but newer projects would simply forbid mis-named methods).

@ghost

ghost commented Feb 20, 2018

Copy link
Copy Markdown
Author

I have modified, sorry for my unskillful patch.

@miss-islington

Copy link
Copy Markdown
Contributor

Thanks @animalize for the PR, and @zooba for merging it 🌮🎉.. I'm working now to backport this PR to: 3.6, 3.7.
🐍🍒⛏🤖

@bedevere-bot

Copy link
Copy Markdown

GH-5910 is a backport of this pull request to the 3.7 branch.

miss-islington pushed a commit to miss-islington/cpython that referenced this pull request Feb 26, 2018
…5523)

(cherry picked from commit 19e7d48)

Co-authored-by: animalize <animalize@users.noreply.github.com>
@miss-islington

Copy link
Copy Markdown
Contributor

Sorry, @animalize and @zooba, I could not cleanly backport this to 3.6 due to a conflict.
Please backport using cherry_picker on command line.
cherry_picker 19e7d48ce89422091f9af93038b9fee075d46e9e 3.6

@bedevere-bot

Copy link
Copy Markdown

GH-5585 is a backport of this pull request to the 3.6 branch.

@bedevere-bot bedevere-bot removed the label Feb 26, 2018
@zooba

zooba commented Feb 26, 2018

Copy link
Copy Markdown
Member

Thanks @animalize!

miss-islington added a commit that referenced this pull request Feb 26, 2018
(cherry picked from commit 19e7d48)

Co-authored-by: animalize <animalize@users.noreply.github.com>
@ghost ghost deleted the issue32394 branch February 27, 2018 09:07
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.

7 participants