#36796 [NEW]: Streams blocking after set non-blocking

From: Date: Mon, 20 Mar 2006 05:37:44 +0000
Subject: #36796 [NEW]: Streams blocking after set non-blocking
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-94619@lists.php.net to get a copy of this message
From: seufert at gmail dot com Operating system: AMD64 Linux 2.6 (Debian) PHP version: 5.1.2 PHP Bug Type: Streams related Bug description: Streams blocking after set non-blocking Description: ------------ Opening a TCP stream, and attempting to access in a non-blocking matter results in fread continuing to block. Reproduce code: --------------- <?php $socket = stream_socket_server('tcp://0.0.0.0:3838'); stream_set_blocking($socket, 0); $conns = array(); $text = ""; while(true){ $new_connection = @stream_socket_accept($socket, 0); print "T"; if(!$new_connection) sleep(1); else { stream_set_blocking($new_connection,0); $conns[] = $new_connection; unset($new_connection); } foreach($conns as $k=>$c) $text .= fread($conns[$k], 8192); foreach($conns as $c) fwrite($c,$text); $text = ""; } ?> Expected result: ---------------- After connecting once or more (with telnet or similar), the program should still tick (will print 'T' to console). Actual result: -------------- Once 1 or more connections are established, the fread blocks, and prevents the program from iterating (or printing 'T' to the console). It will iterate after data is received from all connections. -- Edit bug report at http://bugs.php.net/?id=36796&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=36796&r=trysnapshot44 Try a CVS snapshot (PHP 5.1): http://bugs.php.net/fix.php?id=36796&r=trysnapshot51 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=36796&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=36796&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=36796&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=36796&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=36796&r=needscript Try newer version: http://bugs.php.net/fix.php?id=36796&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=36796&r=support Expected behavior: http://bugs.php.net/fix.php?id=36796&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=36796&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=36796&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=36796&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=36796&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=36796&r=dst IIS Stability: http://bugs.php.net/fix.php?id=36796&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=36796&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=36796&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=36796&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=36796&r=mysqlcfg

« previous php.bugs (#94619) next »