#40566 [Opn->Fbk]: Fgets screws up php on a nonblocked socket

From: Date: Tue, 20 Feb 2007 21:32:04 +0000
Subject: #40566 [Opn->Fbk]: Fgets screws up php on a nonblocked socket
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-109218@lists.php.net to get a copy of this message
ID: 40566 Updated by: tony2001@php.net Reported By: myself at ligesh dot com -Status: Open +Status: Feedback Bug Type: Sockets related Operating System: Linux PHP Version: 5.2.1 New Comment: Please reduce this list of options to the minimum required to replicate the problem. Previous Comments: ------------------------------------------------------------------------ [2007-02-20 21:27:12] myself at ligesh dot com Yeah, That's the correct behaviour. Below are my compile time options. Please note that php-5.2.0 compiled with the same options works fine. ------------------- sh ./configure --prefix=/usr/local/ext/php --with-config-file-path=/usr/local/ext/php/etc --enable-force-cgi-redirect --disable-debug --enable-pic --disable-rpath --enable-cgi --enable-inline-optimization --with-db4=/usr --enable-posix --with-gettext --with-gmp --with-iconv --with-sqlite --with-openssl --with-regex=system --with-expat-dir=/usr --with-dom=shared,/usr --with-dom-xslt=/usr --with-dom-exslt=/usr --with-pcre-regex --with-zlib --enable-simplexml --with-layout=GNU --enable-bcmath --enable-exif --enable-ftp --enable-magic-quotes --enable-safe-mode --enable-sockets --enable-sysvsem --enable-sysvshm --enable-discard-path --enable-track-vars --enable-trans-sid --without-oci8 --with-kerberos --with-mysql=shared,/usr --with-pgsql=shared --enable-memory-limit --enable-bcmath --enable-shmop --enable-dbx --enable-dio --enable-mcal --enable-mbstring --enable-mbstr-enc-trans --enable-mbregex --with-curl=/usr --enable-pcntl make EXTRA_CFLAGS="-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" ------------------------------------------------------------------------ [2007-02-20 21:15:54] tony2001@php.net I see a lot of "Get something". ------------------------------------------------------------------------ [2007-02-20 21:05:49] myself at ligesh dot com OK, i checked with 5.2.0 and it works as expected. Also note that i am using "-D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64" at compile time. Though i don't how this can affect the socket operations. Also the php-5.20 which is working fine, is also compiled with LARGEFILE_SOURCE. So it is something in php 5.2.1 that's causing teh problem. ------------------------------------------------------------------------ [2007-02-20 20:59:03] myself at ligesh dot com Ok, Below is the code that will produce it. The fread should return immediately, and the php should print the message, and then sleep for 1 second, and continue. But instead, u will see php will go into manic loop, INSIDE the fgets, and will not return. There is no problem if it is in blocking mode. The function will not return, but it doesn't become crazy. The version is php 5.2.1. <?php $fd = stream_socket_client("ssl://localhost:443"); stream_set_blocking($fd, false); while (true) { $res = fread($fd, 1024); print("Got something $res\n"); print("\n"); sleep(1); } ------------------------------------------------------------------------ [2007-02-20 20:45:18] tony2001@php.net Thank you for this bug report. To properly diagnose the problem, we need a short but complete example script to be able to reproduce this bug ourselves. A proper reproducing script starts with <?php and ends with ?>, is max. 10-20 lines long and does not require any external resources such as databases, etc. If the script requires a database to demonstrate the issue, please make sure it creates all necessary tables, stored procedures etc. Please avoid embedding huge scripts into the report. Cannot reproduce. ------------------------------------------------------------------------ The remainder of the comments for this report are too long. To view the rest of the comments, please view the bug report online at http://bugs.php.net/40566 -- Edit this bug report at http://bugs.php.net/?id=40566&edit=1

« previous php.bugs (#109218) next »