8000 StreamSelectLoop: Int overflow for big timer intervals by ivkalita · Pull Request #95 · reactphp/event-loop · GitHub
[go: up one dir, main page]

Skip to content

StreamSelectLoop: Int overflow for big timer intervals #95

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

Closed

Conversation

ivkalita
Copy link
Contributor
@ivkalita ivkalita commented Apr 5, 2017

The problem

As described here, current StreamSelectLoop implementation restricts using time intervals more than PHP_INT_MAX microseconds. For 32-bit systems it's only 2148 seconds.

Suggested solution

  • Change StreamSelectLoop $timeout type from int (in microseconds) to float (in seconds);
  • Replace usleep with time_nanosleep, cause usleep takes int argument in microseconds, and we can't keep more than PHP_INT_MAX microseconds. But time_nanosleep takes 2 arguments: int amount of seconds and int amount of nanoseconds, that allows StreamSelectLoop to handle PHP_INT_MAX seconds intervals;
  • Extract stream_select and time_nanosleep methods calls from StreamSelectLoop::streamSelect(...) to test timeout values.

@ivkalita ivkalita force-pushed the stream-select-loop-int-overflow branch from f6e6451 to f1278b3 Compare April 5, 2017 09:05
@ivkalita ivkalita closed this Apr 5, 2017
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.

1 participant
0