10000 StreamSelectLoop timer interval limit fix (on 32-bit systems) by alexmnv · Pull Request #23 · reactphp/event-loop · GitHub
[go: up one dir, main page]

Skip to content

StreamSelectLoop timer interval limit fix (on 32-bit systems) #23

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
wants to merge 1 commit into from
Closed

StreamSelectLoop timer interval limit fix (on 32-bit systems) #23

wants to merge 1 commit into from

Conversation

alexmnv
Copy link
@alexmnv alexmnv commented Feb 5, 2015

Fix timer interval limit issue in \React\EventLoop\StreamSelectLoop (issue #19)
On 32-bit systems it's not possible to set a timer interval higher than 2147 seconds.

@clue
Copy link
Member
clue commented Feb 5, 2015

I have yet to do some more in-depth testing, but on first sight the changes LGTM 👍

Afaict 32-bit systems are becoming increasingly less common, yet this change affects all versions. Is this worth considering, i.e. is the overhead even noticeable?

A slightly less intrusive alternative might be to just cap the maximum $timeout value at an (arbitrary) value. Having the loop tick once every x minutes even when no events occur is unlikely to cause any performance issues.

@WyriHaximus
Copy link
Member

2147 is just over 35 minutes. Tbh if you need a timer to run in 10 minutes or later you maybe should consider a more persistent storage of your timer event. For example dead letter exchanges in rabbitmq. Capping it to x minutes makes more sense to me.

@clue
Copy link
Member
clue commented Mar 8, 2016

Unfortunately this PR is technically a BC break, as consumers could depend on the protected API.

I think it makes sense to fix the underlying issue, but we won't be able merge this into the v0.4 series like this.

@clue
Copy link
Member
clue commented Feb 8, 2017

Ping @alexmnv, what do you think about the above comments?

Also, may I ask you to rebase this on the new "0.4" branch so we get this in for the upcoming v0.4.3 release? :shipit:

@clue clue added this to the v0.4.3 milestone Feb 8, 2017
return stream_select($read, $write, $except, $timeout === null ? null : 0, $timeout);
$tv_sec = $timeout === null ?: floor($timeout);
// convert the fractional part of $timeout to microseconds
$tv_usec = $timeout === null ?: round(fmod($timeout, 1) * self::MICROSECONDS_PER_SECOND);
Copy link
Member
@jsor jsor Feb 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When $timeout === null, both $tv_sec and $tv_usec will become true because of the elvis operator.

This should be

$tv_sec = $timeout === null ? null : floor($timeout);
// convert the fractional part of $timeout to microseconds
$tv_usec = $timeout === null ? null : round(fmod($timeout, 1) * self::MICROSECONDS_PER_SECOND);

Copy link
Author
@alexmnv alexmnv left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jsor You're right. I missed it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0