|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2007-02-20 20:36 UTC] myself at ligesh dot com
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.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Mon Dec 08 22:00:01 2025 UTC |
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); }