Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Fix overflow on large timers #49

Merged
merged 1 commit into from
May 31, 2022
Merged

Fix overflow on large timers #49

merged 1 commit into from
May 31, 2022

Conversation

kelunik
Copy link
Member

@kelunik kelunik commented Feb 4, 2022

@@ -210,7 +210,7 @@ protected function activate(array $callbacks): void
}

if ($callback instanceof TimerCallback) {
$interval = \max(0, $callback->expiration - $now);
$interval = \min(\max(0, $callback->expiration - $now), \PHP_INT_MAX / 2);
Copy link
Member Author

Choose a reason for hiding this comment

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

PHP_INT_MAX / 2 isn't a great solution, and will likely break in 2038 depending on the internal timer used?

@rekryt
Copy link

rekryt commented Feb 14, 2022

I made a visual test application for checking memory leaks. Here's how they can currently be played:
https://github.com/Rekryt/ratchet-revolt-example/blob/master/src/WSExampleTask.php#L18

@trowski trowski merged commit 4e14f0a into main May 31, 2022
@trowski trowski deleted the fix-overflow branch May 31, 2022 22:54
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants