[PHP-DEV] Bug #3187: CPU overload with fopen() and fgets() From: alister <email protected>
Date: 01/12/00

From: alister <email protected>
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;
}

-- 
PHP Development Mailing List <http://www.php.net/>
To unsubscribe, e-mail: php-dev-unsubscribe <email protected>
For additional commands, e-mail: php-dev-help <email protected>
To contact the list administrators, e-mail: php-list-admin <email protected>