8000 Improve default `StreamSelectLoop` to report any warnings for invalid streams passed to `stream_select()` by clue · Pull Request #245 · reactphp/event-loop · GitHub
[go: up one dir, main page]

Skip to content

Improve default StreamSelectLoop to report any warnings for invalid streams passed to stream_select() #245

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 2 commits into from
Feb 22, 2022
Merged
Changes from 1 commit
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
Next Next commit
Do not suppress warnings for invalid streams in stream_select()
  • Loading branch information
clue committed Feb 22, 2022
commit bc0bca9c6d88320d552fecd6d5e755ca081fb6e2
11 changes: 9 additions & 2 deletions src/StreamSelectLoop.php
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,15 @@ private function streamSelect(array &$read, array &$write, $timeout)
}
}

// suppress warnings that occur, when stream_select is interrupted by a signal
$ret = @\stream_select($read, $write, $except, $timeout === null ? null : 0, $timeout);
// suppress warnings that occur when `stream_select()` is interrupted by a signal
\set_error_handler(function ($errno, $errstr) {
$eintr = \defined('SOCKET_EINTR') ? \SOCKET_EINTR : 4;
return ($errno === \E_WARNING && \strpos($errstr, '[' . $eintr .']: ') !== false);
});

$ret = \stream_select($read, $write, $except, $timeout === null ? null : 0, $timeout);

\restore_error_handler();

if ($except) {
$write = \array_merge($write, $except);
Expand Down
0