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] <b614b4a69a>
Closes GH-17174.
Pipes are blocking on Windows, but `php_select()` always returns them
as ready for read/write. This renders the `stream_select()` timeout
useless, what can cause a following read to block for a very long time.
While there is no general fix (and least not within reach for a stable
version), we can at least cater to the important case of read pipes by
peeking the pipe to check whether data is available. If there is none,
we do not add the handle to the read set.
We need to fix a couple of tests cases:
* bug60692.phpt and bug64770.phpt assume that at least the stdin and
stdout pipes are always selected as readable, and that the select
call will not change their order. We're being more defensive now.
* the potentials warnings of bug49936_win32.phpt need to be suppressed,
like it has been done earlier for the POSIX variant of this test
case[1]. Possibly this test case should be dropped altogether[2].
[1] <c884d3782c>
[2] <2c6b85f6fe>
Closes GH-16917.
1. Update: http://www.php.net/license/3_01.txt to https, as there is anyway server header "Location:" to https.
2. Update few license 3.0 to 3.01 as 3.0 states "php 5.1.1, 4.1.1, and earlier".
3. In some license comments is "at through the world-wide-web" while most is without "at", so deleted.
4. fixed indentation in some files before |
These two files have been: "UTF-8 Unicode (with BOM) text".
By applying `dos2unix` on these files the BOM has been removed.
I checked the whole source code with dos2unix:
These were the only two text files affected.
This patch removes the so called local variables defined per
file basis for certain editors to properly show tab width, and
similar settings. These are mainly used by Vim and Emacs editors
yet with recent changes the once working definitions don't work
anymore in Vim without custom plugins or additional configuration.
Neither are these settings synced across the PHP code base.
A simpler and better approach is EditorConfig and fixing code
using some code style fixing tools in the future instead.
This patch also removes the so called modelines for Vim. Modelines
allow Vim editor specifically to set some editor configuration such as
syntax highlighting, indentation style and tab width to be set in the
first line or the last 5 lines per file basis. Since the php test
files have syntax highlighting already set in most editors properly and
EditorConfig takes care of the indentation settings, this patch removes
these as well for the Vim 6.0 and newer versions.
With the removal of local variables for certain editors such as
Emacs and Vim, the footer is also probably not needed anymore when
creating extensions using ext_skel.php script.
Additionally, Vim modelines for setting php syntax and some editor
settings has been removed from some *.phpt files. All these are
mostly not relevant for phpt files neither work properly in the
middle of the file.
The $Id$ keywords were used in Subversion where they can be substituted
with filename, last revision number change, last changed date, and last
user who changed it.
In Git this functionality is different and can be done with Git attribute
ident. These need to be defined manually for each file in the
.gitattributes file and are afterwards replaced with 40-character
hexadecimal blob object name which is based only on the particular file
contents.
This patch simplifies handling of $Id$ keywords by removing them since
they are not used anymore.
This warning was about a possible loss of data due to the downcast of `php_socket_t` to `int`. The former maps to a platform specific type, hence, it might downcast from a 64 bit integer to a 32 bit intger.
Fixed possibly overflowing vars
Due to the change from `int` to `php_socket_t` some variables might overflow now. Changed all variables that might be affected.
Revert "Fixed possibly overflowing vars"
This reverts commit bf64fd5984.
Use aliased PHP socket type
Using the alias protects us from changes to the underlying type.
Removed ignored nfds argument
The `nfds` argument to the Win32 `select` function is always ignored, regardless of its actual value. Hence, we should not pass it in the first place. See https://msdn.microsoft.com/en-us/library/windows/desktop/ms740141(v=vs.85).aspx for reference.
Target value is not a pointer
Avoid overflow in loop
The old code implicitly set any sockets into non-blocking mode,
and since there is no way to probe a socket to determine its
blocking status using the win32 API, this was a real pain in the ass.
The New implementation will hand off any sockets to winsock and
use the WaitForObject API in win32 to probe other types of handle.