#46024 [Opn]: stream_select doesn't return the correct number
ID: 46024
User updated by: mike at silverorange dot com
Reported By: mike at silverorange dot com
Status: Open
Bug Type: Streams related
Operating System: linux
PHP Version: 5.2CVS-2008-09-09 (snap)
New Comment:
If I use 8192 as the number of bytes for fread(), the correct value is
returned. Examining the program with strace() reveals:
- PHP always reads 8192 bytes from fread
- the requested bytes are returned and the remaining bytes are
buffered
- stream_select() only invokes a system select() call if the internal
buffer is empty
- stream_select() returns the wrong value if no actual system select()
call is performed.
See additional test cases at the above link.
Previous Comments:
------------------------------------------------------------------------
[2008-09-09 03:30:03] mike at silverorange dot com
The test also fails on the provided snapshot.
------------------------------------------------------------------------
[2008-09-08 14:33:47] mike at silverorange dot com
Description:
------------
The stream_select function should return the number of streams ready in
the read and write arrays. Sometimes it does and sometimes it doesn't.
Reproduce code:
---------------
http://labs.silverorange.com/files/stream-select-bug/
Expected result:
----------------
selecting ... got 2
Array ( [0] => Resource id #5 )
Array ( [0] => Resource id #6 )
selecting ... got 2
Array ( [0] => Resource id #5 )
Array ( [0] => Resource id #6 )
Actual result:
--------------
selecting ... got 2
Array ( [0] => Resource id #5 )
Array ( [0] => Resource id #6 )
selecting ... got 1
Array ( [0] => Resource id #5 )
Array ( [0] => Resource id #6 )
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=46024&edit=1
Thread (5 messages)