php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #46024 stream_select() doesn't return the correct number
Submitted: 2008-09-08 14:33 UTC Modified: 2008-11-04 00:43 UTC
From: mike at silverorange dot com Assigned:
Status: Closed Package: Streams related
PHP Version: 5.2CVS-2008-09-09 (snap) OS: linux
Private report: No CVE-ID: None
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
Package:
Bug Type:
Summary:
From: mike at silverorange dot com
New email:
PHP Version: OS:

 

 [2008-09-08 14:33 UTC] 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 )

Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2008-09-09 03:30 UTC] mike at silverorange dot com
The test also fails on the provided snapshot.
 [2008-09-15 02:58 UTC] mike at silverorange dot com
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.
 [2008-11-04 00:43 UTC] lbarnaud@php.net
This bug has been fixed in CVS.

Snapshots of the sources are packaged every three hours; this change
will be in the next snapshot. You can grab the snapshot at
http://snaps.php.net/.
 
Thank you for the report, and for helping us make PHP better.


 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Dec 27 05:01:27 2024 UTC