|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
[2009-06-25 08:37 UTC] sjoerd-php at linuxonly dot nl
[2009-07-05 02:36 UTC] php at richardneill dot org
[2009-07-24 09:32 UTC] jani@php.net
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 03:00:01 2025 UTC |
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!