[php-src] PR #23793: ext/standard: Fix Io\Poll timeouts longer than INT_MAX milliseconds
| From: | nicolas-grekas | Date: | Sun, 20 Sep 2026 15:00:41 +0000 |
| Subject: | [php-src] PR #23793: ext/standard: Fix Io\Poll timeouts longer than INT_MAX milliseconds | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-38631@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/23793
Author: nicolas-grekas
Also found while building an
Io\Poll driver for revolt/event-loop, unrelated to #23791.
php_poll_timespec_to_ms() casts tv_sec * 1000 to an int, so a
timeout of more than about 24 days wraps around and wait() returns almost at once:
```php
$ctx = new Io\Poll\Context(Io\Poll\Backend::Poll);
$ctx->add(new StreamPollHandle($socket), [Io\Poll\Event::Read]);
$ctx->wait(Time\Duration::fromSeconds(158913790)); // five years, returns empty after 50ms
```
The value is capped at INT_MAX now. This hits the poll and WSAPoll
backends, and epoll only where it falls back to epoll_wait(), since
epoll_pwait2() takes the timespec as is.
A timeout beyond 24 days still ends early, without any event, which is what the other users of that
helper already assume. Waiting the whole duration would mean looping in each backend, tell me if you
would rather have that.