#41371 [NEW]: stream_set_blocking bug with sockets

From: Date: Sat, 12 May 2007 00:49:08 +0000
Subject: #41371 [NEW]: stream_set_blocking bug with sockets
Groups: php.bugs 
Request: Send a blank email to php-bugs+get-112566@lists.php.net to get a copy of this message
From: six at aegis-corp dot org Operating system: Linux 2.6 PHP version: 5.2.2 PHP Bug Type: Streams related Bug description: stream_set_blocking bug with sockets Description: ------------ When a stream has been obtained using stream_socket_accept from a non-blocking server, php believes that it is itself non-blocking and refuses to set it non blocking after a call to stream_set_blocking. Reproduce code: --------------- <? $s = stream_socket_server("tcp://0.0.0.0:12345"); stream_set_blocking($s, false); $c = stream_socket_accept($s); // code will work if uncommented //stream_set_blocking($c, true); stream_set_blocking($c, false); ?> Expected result: ---------------- Expected result is that $c is non-blocking, which it is *not* unless the previous stream_set_blocking($c, true) is uncommented (this may reset some internal cache ?) Actual result: -------------- reproduce code strace: listen(3, 5) = 0 fcntl64(3, F_GETFL) = 0x2 (flags O_RDWR) fcntl64(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0 poll([{fd=3, events=POLLIN|POLLERR|POLLHUP, revents=POLLIN}], 1, 60000) = 1 accept(3, {sa_family=AF_INET, sin_port=htons(58901), sin_addr=inet_addr("127.0.0.1")}, [16]) = 4 [stream_set_blocking($c, false) does nothing here] close(4) = 0 close(3) = 0 [script ends] reproduce code strace with second call uncommented : listen(3, 5) = 0 fcntl64(3, F_GETFL) = 0x2 (flags O_RDWR) fcntl64(3, F_SETFL, O_RDWR|O_NONBLOCK) = 0 poll([{fd=3, events=POLLIN|POLLERR|POLLHUP, revents=POLLIN}], 1, 60000) = 1 accept(3, {sa_family=AF_INET, sin_port=htons(58901), sin_addr=inet_addr("127.0.0.1")}, [16]) = 4 fcntl64(4, F_GETFL) = 0x2 (flags O_RDWR) fcntl64(4, F_SETFL, O_RDWR) = 0 fcntl64(4, F_GETFL) = 0x2 (flags O_RDWR) fcntl64(4, F_SETFL, O_RDWR|O_NONBLOCK) = 0 [the two stream_set_blocking calls work here] close(4) = 0 close(3) = 0 [script ends] -- Edit bug report at http://bugs.php.net/?id=41371&edit=1 -- Try a CVS snapshot (PHP 4.4): http://bugs.php.net/fix.php?id=41371&r=trysnapshot44 Try a CVS snapshot (PHP 5.2): http://bugs.php.net/fix.php?id=41371&r=trysnapshot52 Try a CVS snapshot (PHP 6.0): http://bugs.php.net/fix.php?id=41371&r=trysnapshot60 Fixed in CVS: http://bugs.php.net/fix.php?id=41371&r=fixedcvs Fixed in release: http://bugs.php.net/fix.php?id=41371&r=alreadyfixed Need backtrace: http://bugs.php.net/fix.php?id=41371&r=needtrace Need Reproduce Script: http://bugs.php.net/fix.php?id=41371&r=needscript Try newer version: http://bugs.php.net/fix.php?id=41371&r=oldversion Not developer issue: http://bugs.php.net/fix.php?id=41371&r=support Expected behavior: http://bugs.php.net/fix.php?id=41371&r=notwrong Not enough info: http://bugs.php.net/fix.php?id=41371&r=notenoughinfo Submitted twice: http://bugs.php.net/fix.php?id=41371&r=submittedtwice register_globals: http://bugs.php.net/fix.php?id=41371&r=globals PHP 3 support discontinued: http://bugs.php.net/fix.php?id=41371&r=php3 Daylight Savings: http://bugs.php.net/fix.php?id=41371&r=dst IIS Stability: http://bugs.php.net/fix.php?id=41371&r=isapi Install GNU Sed: http://bugs.php.net/fix.php?id=41371&r=gnused Floating point limitations: http://bugs.php.net/fix.php?id=41371&r=float No Zend Extensions: http://bugs.php.net/fix.php?id=41371&r=nozend MySQL Configuration Error: http://bugs.php.net/fix.php?id=41371&r=mysqlcfg

« previous php.bugs (#112566) next »