From: myself at ligesh dot com
Operating system: Linux
PHP version: 5.2.1
PHP Bug Type: Sockets related
Bug description: Fgets screws up php on a nonblocked socket
Description:
------------
If i do an fgets on a socket that has been noblocked using
stream_set_blocking($fp, false);, then php goes into a loop.
stream_set_blocking($socket, false);
fgets($socket, 1024);
Instead of returning instantly at teh fgets, php goes into an internal
loop. The strace is:
--------------
read(4, 0x98b9180, 5) = -1 EAGAIN (Resource temporarily
unavailable)
Continiously repeated.
--------------------
This is a very nasty bug, and i am really suprised how it got in there.
It was working fine with 5.2.0, but i made a mistake of upgrading to 5.2.1
and my major program has completely broken down.
Reproduce code:
---------------
----------
$fd = stream_socket_client("ssl://$serv_addr:$serv_port")
stream_set_blocking($fd, false);
fgets($fd, 1024);
-------------
Expected result:
----------------
Return immediately.
Actual result:
--------------
Goes into a manic loop of read returning einval.
--
Edit bug report at http://bugs.php.net/?id=40566&edit=1
--
Try a CVS snapshot (PHP 4.4):
http://bugs.php.net/fix.php?id=40566&r=trysnapshot44
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=40566&r=trysnapshot52
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=40566&r=trysnapshot60
Fixed in CVS: http://bugs.php.net/fix.php?id=40566&r=fixedcvs
Fixed in release:
http://bugs.php.net/fix.php?id=40566&r=alreadyfixed
Need backtrace: http://bugs.php.net/fix.php?id=40566&r=needtrace
Need Reproduce Script: http://bugs.php.net/fix.php?id=40566&r=needscript
Try newer version: http://bugs.php.net/fix.php?id=40566&r=oldversion
Not developer issue: http://bugs.php.net/fix.php?id=40566&r=support
Expected behavior: http://bugs.php.net/fix.php?id=40566&r=notwrong
Not enough info:
http://bugs.php.net/fix.php?id=40566&r=notenoughinfo
Submitted twice:
http://bugs.php.net/fix.php?id=40566&r=submittedtwice
register_globals: http://bugs.php.net/fix.php?id=40566&r=globals
PHP 3 support discontinued: http://bugs.php.net/fix.php?id=40566&r=php3
Daylight Savings: http://bugs.php.net/fix.php?id=40566&r=dst
IIS Stability: http://bugs.php.net/fix.php?id=40566&r=isapi
Install GNU Sed: http://bugs.php.net/fix.php?id=40566&r=gnused
Floating point limitations: http://bugs.php.net/fix.php?id=40566&r=float
No Zend Extensions: http://bugs.php.net/fix.php?id=40566&r=nozend
MySQL Configuration Error: http://bugs.php.net/fix.php?id=40566&r=mysqlcfg