Skip to content

Commit c9d7d46

Browse files
committedJan 25, 2024
fix: fix race condition in SystemClock
1 parent 8edc07a commit c9d7d46

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed
 

‎src/Scheduling/Timing/SystemClock.php

+4-3
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,14 @@ public function sleep(int $seconds): void
3232

3333
public function sleepUntil(DateTimeImmutable $date): void
3434
{
35-
$now = $this->now();
35+
$now = $this->now()->getTimestamp();
36+
$target = $date->getTimestamp();
3637

37-
if ($now >= $date) {
38+
if ($target <= $now) {
3839
return;
3940
}
4041

4142
/** @psalm-suppress UnusedFunctionCall */
42-
\time_sleep_until($date->getTimestamp());
43+
\time_sleep_until($target);
4344
}
4445
}

0 commit comments

Comments
 (0)
Please sign in to comment.