-
Notifications
You must be signed in to change notification settings - Fork 8k
ext/standard: Improve handling of timeout values #16246
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
base: master
Are you sure you want to change the base?
Conversation
@cmb69 quick question, I see that I'm guessing if I do |
@Girgias, you can use #include "win32/time.h" |
84861ea
to
e595ede
Compare
e595ede
to
822dc1a
Compare
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.
Overall this looks reasonable.
} else if (usec >= 1000000) { | ||
php_error_docref(NULL, E_WARNING, "must be less than 1000000"); | ||
if (UNEXPECTED(EG(exception))) { | ||
RETURN_THROWS(); | ||
} |
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.
Can't this just be a zend_argument_value_error
? We've shipped improved parameter validation all the time without an RFC and here the <0
case already throws.
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.
I don't know if people rely on passing a large int or not for the microseconds
zend_argument_value_error(4, "must be greater than or equal to 0"); | ||
RETURN_THROWS(); | ||
} else if (usec < 0) { | ||
zend_argument_value_error(5, "must be greater than or equal to 0"); |
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.
Could update the message to must be between 0 and 999999
to be consistent with stream_set_timeout
.
|
||
/* prepare the timeout value for use */ | ||
struct timeval *tv_pointer; | ||
if (timeout < 0.0 || timeout >= (double) PHP_TIMEOUT_ULL_MAX / 1000000.0) { |
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.
Do we no longer need the overflow check?
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.
We probably do, actually.
No description provided.