8000 [RateLimiter] Fix sleep value by jderusse · Pull Request #40658 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[RateLimiter] Fix sleep value #40658

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

Merged
merged 1 commit into from
Apr 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Fix sleep value
  • Loading branch information
jderusse committed Mar 31, 2021
commit cf663993997a4c56aa8077656d53838005d23562
7 changes: 6 additions & 1 deletion src/Symfony/Component/RateLimiter/RateLimit.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,11 @@ public function getLimit(): int

public function wait(): void
{
sleep(($this->retryAfter->getTimestamp() - time()) * 1e6);
$delta = $this->retryAfter->getTimestamp() - time();
if ($delta <= 0) {
return;
}

sleep($delta);
}
}
0