From: php at richardneill dot org Operating system: Linux PHP version: 5.2CVS-2009-06-25 (snap) PHP Bug Type: Streams related Bug description: stream_select returns 1 even when no streams have changed
Description: ------------ It seems that stream_select is failing to return 0 even if all of the streams would block. I've tested the code below on multiple versions of PHP from 5.2.4 upward, and get the same result on them all. (It's possible I've misunderstood the requirements for sockets, but I've quintuple-checked this code.) Reproduce code: --------------- #!/usr/bin/php <? echo "This should never print 'did fread'.\n"; echo "It should just print 'stream_select returned 0' every second\n"; echo "\n"; $fp=fopen("/dev/null",r); #open /dev/null for reading. #Should immediately result in EOF. while (true) { $r = array($fp); $n = stream_select($r, $w = null, $e = null, 1); #stream select on read array, timeout 1 sec echo "stream_select returned $n\n"; if ($n) { #Try to read up to 1024 bytes echo fread($fp,1024); echo "did fread.\n"; } usleep (100000); //slow down (0.1s) } ?> Expected result: ---------------- I expect to see the line stream_select returned 0 repeated every 1 second. Actual result: -------------- I get repeated instances of: stream_select returned 1 did fread. fread is returning nothing, but still the stream_select insists that there is data available to be read! -- Edit bug report at http://bugs.php.net/?id=48683&edit=1 -- Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=48683&r=trysnapshot52 Try a CVS snapshot (PHP 5.3): http://bugs.php.net/fix.php?id=48683&r=trysnapshot53 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=48683&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=48683&r=fixedcvs Fixed in CVS and need be documented: http://bugs.php.net/fix.php?id=48683&r=needdocs Fixed in release: http://bugs.php.net/fix.php?id=48683&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=48683&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=48683&r=needscript Try newer version: http://bugs.php.net/fix.php?id=48683&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=48683&r=support Expected behavior: http://bugs.php.net/fix.php?id=48683&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=48683&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=48683&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=48683&r=globals PHP 4 support discontinued: http://bugs.php.net/fix.php?id=48683&r=php4 Daylight Savings: http://bugs.php.net/fix.php?id=48683&r=dst IIS Stability: http://bugs.php.net/fix.php?id=48683&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=48683&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=48683&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=48683&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=48683&r=mysqlcfg