gh-126876: Fix socket internal_select() for large timeout#126968
Merged
vstinner merged 2 commits intopython:mainfrom Nov 19, 2024
Merged
gh-126876: Fix socket internal_select() for large timeout#126968vstinner merged 2 commits intopython:mainfrom
vstinner merged 2 commits intopython:mainfrom
Conversation
If the timeout is larger than INT_MAX, replace it with INT_MAX, in the poll() code path. Add an unit test.
Member
Author
|
cc @sobolevn |
Member
Author
|
With this change, select() and poll() code paths have the same behavior: saturate the timeout to the implementation maximum. |
sobolevn
approved these changes
Nov 18, 2024
| /* s->sock_timeout is in seconds, timeout in ms */ | ||
| ms = _PyTime_AsMilliseconds(interval, _PyTime_ROUND_CEILING); | ||
| assert(ms <= INT_MAX); | ||
| if (ms > INT_MAX) { |
Member
There was a problem hiding this comment.
Yes, indeed my proposal was wrong. Because later ms is casted to int: n = poll(&pollfd, 1, (int)ms);
Thanks for picking this up!
Member
Author
|
The test fails on Windows: I modified the test to skip the test if settimeout() raises OverflowError (on Windows). |
ruidazeng
approved these changes
Nov 19, 2024
|
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.12, 3.13. |
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this pull request
Nov 19, 2024
…onGH-126968) If the timeout is larger than INT_MAX, replace it with INT_MAX, in the poll() code path. Add an unit test. (cherry picked from commit b3687ad) Co-authored-by: Victor Stinner <vstinner@python.org>
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this pull request
Nov 19, 2024
…onGH-126968) If the timeout is larger than INT_MAX, replace it with INT_MAX, in the poll() code path. Add an unit test. (cherry picked from commit b3687ad) Co-authored-by: Victor Stinner <vstinner@python.org>
|
GH-127002 is a backport of this pull request to the 3.13 branch. |
|
GH-127003 is a backport of this pull request to the 3.12 branch. |
ebonnal
pushed a commit
to ebonnal/cpython
that referenced
this pull request
Jan 12, 2025
…on#126968) If the timeout is larger than INT_MAX, replace it with INT_MAX, in the poll() code path. Add an unit test.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
If the timeout is larger than INT_MAX, replace it with INT_MAX, in the poll() code path.
Add an unit test.
socketwith too large default timeout (larger than INT_MAX) #126876