8000 bug #40658 [RateLimiter] Fix sleep value (jderusse) · symfony/symfony@4d23fec · GitHub
[go: up one dir, main page]

Skip to content

Commit 4d23fec

Browse files
bug #40658 [RateLimiter] Fix sleep value (jderusse)
This PR was merged into the 5.2 branch. Discussion ---------- [RateLimiter] Fix sleep value | Q | A | ------------- | --- | Branch? | 5.2 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #40656 | License | MIT | Doc PR | sleep vs usleep Commits ------- cf66399 Fix sleep value
2 parents f9e38df + cf66399 commit 4d23fec

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/Symfony/Component/RateLimiter/RateLimit.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,11 @@ public function getLimit(): int
6767

6868
public function wait(): void
6969
{
70-
sleep(($this->retryAfter->getTimestamp() - time()) * 1e6);
70+
$delta = $this->retryAfter->getTimestamp() - time();
71+
if ($delta <= 0) {
72+
return;
73+
}
74+
75+
sleep($delta);
7176
}
7277
}

0 commit comments

Comments
 (0)
0