ID: 41371 Updated by: [EMAIL PROTECTED] Reported By: six at aegis-corp dot org -Status: Verified +Status: Closed Bug Type: Streams related Operating System: Linux 2.6 PHP Version: 5.2.2 New Comment:
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. Previous Comments: ------------------------------------------------------------------------ [2007-05-13 23:43:50] [EMAIL PROTECTED] And that's exactly the reason for this bug. :D ------------------------------------------------------------------------ [2007-05-13 22:05:29] [EMAIL PROTECTED] And note: fctnl() is called only when needed in the streams code. (if stream is already blocked -> fcntl won't be called at all) ------------------------------------------------------------------------ [2007-05-13 21:42:23] [EMAIL PROTECTED] This works just fine for me without having 2 stream_set_blocking() calls. Are you sure you're using PHP 5.2.2? And is that strace from exactly that script you pasted here? And what was the configure line used to configure PHP? ------------------------------------------------------------------------ [2007-05-12 00:49:08] six at aegis-corp dot org 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 this bug report at http://bugs.php.net/?id=41371&edit=1