[php-src] PR #17174: Improve fix for GH-16889
| From: | cmb69 | Date: | Mon, 16 Dec 2024 12:51:04 +0000 |
| Subject: | [php-src] PR #17174: Improve fix for GH-16889 | ||
| Groups: | php.git-pulls | ||
| Request: | Send a blank email to git-pulls+get-30023@lists.php.net to get a copy of this message | ||
Pull Request: https://github.com/php/php-src/pull/17174
Author: cmb69
The original patch[1] cared only about pipe handles in the rset, but would be problematic if there
are other handles (e.g. files in the rset, or pipes/files in the other sets), because
php_select() would return immediately, reporting all non read-pipe handles as ready,
but possibly never reporting read-pipe handles.
We fix this by applying different logic for the case where only pipe handles are supplied in the
rset, but no handles in the wset or eset. In this case php_select() only returns when
actually one of the handles is ready, or when the timeout expires. To avoid busy looping in this
case, we sleep for a short amount of time. This matches POSIX behavior.
In all other cases, php_select() behaves as before (i.e. prior to the original fix),
that is it returns immediately, reporting all handles as ready.
We also add a test case that demonstrates multiplexing the output of a couple of child processes.
See also the discussion on <https://github.com/php/php-src/pull/16917>.
[1] <https://github.com/php/php-src/commit/b614b4a69ae7bab13c39af2f4a01dea846dfa307>
---
If we merge this, it deservers a mention in UPGRADING.