-
Notifications
You must be signed in to change notification settings - Fork 122
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
Clamp long timeouts (like Duration::MAX) #208
Merged
Merged
Conversation
This file contains 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
sirhcel
force-pushed
the
fix-read-timeout-max
branch
from
August 1, 2024 10:11
55f5dd0
to
bc4596f
Compare
sirhcel
changed the title
Fix large read timeouts (like Duration::MAX)
Clamp long timeouts (like Duration::MAX)
Aug 1, 2024
They bubbled up when locally using rust-analyzer and Clippy 1.80.
This prepares unit-testing them.
sirhcel
force-pushed
the
fix-read-timeout-max
branch
2 times, most recently
from
August 2, 2024 17:40
b409430
to
1517bca
Compare
The previous timeout calculation overflowed at a cast and resulted in negative timeouts. These in turn resulted in errors from ppoll.
sirhcel
force-pushed
the
fix-read-timeout-max
branch
from
August 2, 2024 19:34
1517bca
to
b622588
Compare
sirhcel
force-pushed
the
fix-read-timeout-max
branch
from
August 2, 2024 20:34
90d5b5e
to
5e515cc
Compare
eldruin
approved these changes
Aug 5, 2024
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.
Very thorough. Thank you!
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.
This PR fixes #207 by clamping long timeouts to the capabilities of the underlying platform. Thin preserves monoticity for for the conversion of
Duration
values and does not expose the details of the conversion methods previously used for the different platforms like:This is especially unpleasant as we are currently recommending using
Duration::MAX
as "no timeout" (#12).In theory, this trades accuracy of long timeouts in. In practice, long timeouts already exhibited unexpected and faulty behavior from returning error to panicking due to arithmetic overflows.
It looks like no platform uses an actual timeout data type smaller than
i32
. So even in combination with expressing timeouts as milliseconds, this gives about 24 days for which timeouts could be expressed accurately. Everything beyond can likely be handled witch lesser precision and spurious timeouts.