function StreamSelectDriver::__construct
Overrides AbstractDriver::__construct
File
-
vendor/
revolt/ event-loop/ src/ EventLoop/ Driver/ StreamSelectDriver.php, line 46
Class
Namespace
Revolt\EventLoop\DriverCode
public function __construct() {
parent::__construct();
$this->signalQueue = new \SplQueue();
$this->timerQueue = new TimerQueue();
$this->signalHandling = \extension_loaded("pcntl") && \function_exists('pcntl_signal_dispatch') && \function_exists('pcntl_signal');
$this->streamSelectErrorHandler = function (int $errno, string $message) : void {
// Casing changed in PHP 8 from 'unable' to 'Unable'
if (\stripos($message, "stream_select(): unable to select [4]: ") === 0) {
// EINTR
$this->streamSelectIgnoreResult = true;
return;
}
if (\str_contains($message, 'FD_SETSIZE')) {
$message = \str_replace([
"\r\n",
"\n",
"\r",
], " ", $message);
$pattern = '(stream_select\\(\\): You MUST recompile PHP with a larger value of FD_SETSIZE. It is set to (\\d+), but you have descriptors numbered at least as high as (\\d+)\\.)';
if (\preg_match($pattern, $message, $match)) {
$helpLink = 'https://revolt.run/extensions';
$message = 'You have reached the limits of stream_select(). It has a FD_SETSIZE of ' . $match[1] . ', but you have file descriptors numbered at least as high as ' . $match[2] . '. ' . "You can install one of the extensions listed on {$helpLink} to support a higher number of " . "concurrent file descriptors. If a large number of open file descriptors is unexpected, you " . "might be leaking file descriptors that aren't closed correctly.";
}
}
throw new \Exception($message, $errno);
};
}