Bug #3187: CPU overload with fopen() and fgets()
| From: | alister at xcel dot net dot au | Date: | Wed, 12 Jan 2000 11:15:12 +0000 |
| Subject: | Bug #3187: CPU overload with fopen() and fgets() | ||
| Groups: | php.dev | ||
| Request: | Send a blank email to php-dev+get-14522@lists.php.net to get a copy of this message | ||
From: alister@xcel.net.au
Operating system: NT 4.0 SP 5 on intel
PHP version: 3.0.14
PHP Bug Type: Misbehaving function
Bug description: CPU overload with fopen() and fgets()
I'm using latest release PHP4 beta 3 (couldn't pick that as a selection in the PHP Version
pull-down - sorry). Also latest win32 Apache.
When I run the code below on an external URL (in this case http://directory.netscape.com/) PHP gets as far as
entering the while loop but appears to go out of control on the fgets(). I am getting variable CPU
usage between 95 and 100%... it's maxing out my processor! I don't know how long it would
go for... I eventually rebooted (manuy times!) because I couldn't kill the PHP.exe process.
NOTE: The script max timeout variable doesn't work outside UNIX and this is something to
overcome, please!
I tried a work around using readfile() and explode() to get the array back, but readfile() sends to
standard output and I don't know how to suppress this.
I'm notifying of this bug (I'm not alone... there's a note on one of the online
manual pages about the exact same error in PHP v3.something) but also asking for any workarounds for
the time being.
Thanks,
ALister.
-------------------------------------------------
function grabFile ($url, $ignoreme)
{
$fp = fopen ($url, "r");
$i = 0;
echo " ";
flush ();
while (!feof($fp))
{
$file[$i] .= fgets ($fp,1024);
$i++;
//echo $i." <br>";
flush ();
}
echo " ";
flush ();
return $file;
}