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

From: Date: Tue, 20 Feb 2007 20:45:18 +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-109213@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: 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. Previous Comments: ------------------------------------------------------------------------ [2007-02-20 20:36:51] 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. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=40566&edit=1

« previous php.bugs (#109213) next »