Skip to content

Improve fix for GH-16889 #17174

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

Closed
wants to merge 1 commit into from
Closed

Improve fix for GH-16889 #17174

wants to merge 1 commit into from

Conversation

cmb69
Copy link
Member

@cmb69 cmb69 commented Dec 16, 2024

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 #16917.

[1] b614b4a


If we merge this, it deservers a mention in UPGRADING.

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 <php#16917>.

[1] <php@b614b4a>
@cmb69 cmb69 marked this pull request as ready for review December 16, 2024 13:22
@cmb69 cmb69 requested a review from bukka as a code owner December 16, 2024 13:22
@cmb69
Copy link
Member Author

cmb69 commented Dec 16, 2024

Interestingly, the previous fix increased the time to run the test suite on Windows by a couple of minutes, while this follow-up appears to bring back the old performance.

@cmb69 cmb69 closed this in 6972612 Dec 16, 2024
@cmb69 cmb69 deleted the cmb/gh16889++ branch December 16, 2024 22:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants