-
-
Notifications
You must be signed in to change notification settings - Fork 968
Avoid rounding issues when checking Timeout values (#1700) #1712
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
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.
Pull Request Overview
This PR fixes a rounding issue in the AsTimeout extension method that was causing incorrect timeout validation failures. The issue occurred when checking Timeout.InfiniteTimeSpan values due to floating-point precision problems that were compiler/optimization dependent.
- Changed timeout calculation from
doubletolongto avoid floating-point rounding issues - Updated the range check to use integer comparison instead of floating-point comparison
- Enhanced the exception message to include the actual timeout value for better debugging
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
It can be argued that the range check is completely unnecessary when called from the SshCommand ctor (as it is always called with |
AsTimeout is called from the SshCommand constructor with Timeout.InfiniteTimeSpan. In this scenario the range check should never fail, but unfortunately it does in certain scenarios, due to a runtime or compiler bug (as soon as optimizations are turned off the issue miraculously disappears). Closes sshnet#1700
|
I had half-fixed the tests that were asserting too strictly against the original commit, so I finished that and reverted to the original. Making the comparison on Thanks! |
AsTimeout is called from the SshCommand constructor with Timeout.InfiniteTimeSpan. In this scenario the range check should never fail, but unfortunately it does in certain scenarios, due to a runtime or compiler bug (as soon as optimizations are turned off the issue miraculously disappears).
Closes #1700