#46049 [Asn]: feof() hangs
| From: | dsp@php.net | Date: | Wed, 05 Nov 2008 13:43:24 +0000 |
| Subject: | #46049 [Asn]: feof() hangs | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-130649@lists.php.net to get a copy of this message | ||
ID: 46049
Updated by: dsp@php.net
Reported By: sebastian@php.net
Status: Assigned
Bug Type: Streams related
Operating System: Linux
PHP Version: 5.3CVS-2008-09-11 (CVS)
Assigned To: dsp
New Comment:
Jani: I think it's an issue with the ssl socks, as my patch didn't
patch
those. I try to have time to have a look on this, but I
cannot reproduce the patch yet even though I sit down with sebstian and
try to figure out what's going wrong.
Previous Comments:
------------------------------------------------------------------------
[2008-10-28 22:08:32] jani@php.net
David, I guess we just have to revert that bad patch of yours then?
------------------------------------------------------------------------
[2008-09-11 12:17:57] tony2001@php.net
David, it appears that this problem is caused by this patch of yours:
http://news.php.net/php.cvs/52689
Take a look at it please.
------------------------------------------------------------------------
[2008-09-11 12:13:58] sebastian@php.net
Description:
------------
The code below works fine with PHP 5.2.6 (and earlier), but not with
the unreleased PHP 5.2.7 and PHP 5.3.0:
892 $handle = @fopen($url, 'r');
893
894 if (!$handle) {
895 throw new RuntimeException(
896 'Could not connect to the Selenium RC server.'
897 );
898 }
899
900 stream_set_blocking($handle, 1);
901 stream_set_timeout($handle, 0, $this->timeout);
902
903 $info = stream_get_meta_data($handle);
904 $response = '';
905
906 while ((!feof($handle)) && (!$info['timed_out'])) {
907 $response .= fgets($handle, 4096);
908 $info = stream_get_meta_data($handle);
909 }
910
911 fclose($handle);
The code above hangs with PHP 5.2.7 and PHP 5.3.0 in line 906 as shown
using Xdebug's tracing:
fopen() Driver.php:892
stream_set_blocking() Driver.php:900
stream_set_timeout() Driver.php:901
stream_get_meta_data() Driver.php:903
feof() Driver.php:906
fgets() Driver.php:907
stream_get_meta_data() Driver.php:908
feof() Driver.php:906
The second feof() call above hangs.
More information can be found here:
- http://static.phpunit.de/trace.818532121.xt
- http://static.phpunit.de/strace.txt
Changing the loop to
while (!$info['eof'] && !$info['timed_out']) {
$response .= fgets($handle, 4096);
$info = stream_get_meta_data($handle);
}
fixes the problem. This means a difference between feof() and
$info['eof'].
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=46049&edit=1