Re: PHP 4.0 Bug #10092 Updated: Socket fgets memory and CPU usage problem

From: Date: Wed, 18 Apr 2001 15:04:54 +0000
Subject: Re: PHP 4.0 Bug #10092 Updated: Socket fgets memory and CPU usage problem
References: 1  Groups: php.dev 
Request: Send a blank email to php-dev+get-51881@lists.php.net to get a copy of this message
Hi Jani this is the code that reproduces the bug. I've posted it to the bug db too Cheers Jakub --------------------- <!-- This is a PHP POP3 Socket Test that demonstrates a Windows PHP CGI bug which consumes the transfered data thru the socket and never releases them. Each round of the for cycle below gets slower and slower and never finishes the end. To test it edit the POP3 server variables below. Make sure there's only one 500K message in the POP3 mailbox. Then run the test. Currently the PHP gives up in the 11th cycle. On windows 9x the PHP stops running. On windows NT/2000 the PHP goes crazy, consumes 100% CPU and never finishes. Please, contact me: Jakub Klos jakub@icewarp.com --> <HTML> <HEAD> <TITLE>Test</TITLE> </HEAD> <BODY> PHP POP3 Socket Test<BR><BR> <? $server = "localhost"; $port = 110; $user = "user"; $pass = "pass"; $round = 20; // connect to the POP3 server and read the response $socket = fsockopen($server, $port); $line = fgets($socket, 1024); // USER and PASS commands fputs($socket, "USER $user\r\n"); $line = fgets($socket, 1024); fputs($socket, "PASS $pass\r\n"); $line = fgets($socket, 1024); $length = 0; for ($i = 1; $i < $round + 1; $i++) { // RETR command to receive the message fputs($socket, "RETR 1\r\n"); $line = fgets($socket, 1024); if ($line[0] == "-") break; while (($line = fgets($socket, 1024)) <> ".\r\n") { if (!($line)) break; $length += strlen($line); } echo "Round $i/$round, Transfered $length<BR>"; flush(); } fclose($socket); echo "Total bytes received: $length"; ?> </BODY> </HTML> ------------------------- > ID: 10092 > Updated by: sniper > Reported By: jakub@icewarp.com > Old-Status: Open > Status: Feedback > Bug Type: Sockets related > Assigned To: > Comments: > > Please add a self containing short script into this report > > which can be used to reproduce this problem. > > --Jani > > Previous Comments: > --------------------------------------------------------------------------- > > [2001-03-31 09:56:39] jakub@icewarp.com > When using the fgets function for large data transmission the data transmitted are never freed > from memory. When using fgets with files it works fine. The PHP CGI module starts to utilize the CPU > to 100% and never ends, stops processing and doesn't exit the fgets function after few read > cycles. This happens only on Windows PHP CGI. We tested Apache and that worked fine. Even the > previous version of PHP did that. Large data I'm talking about is 8MB and above. > > --------------------------------------------------------------------------- > > ATTENTION! Do NOT reply to this email! > To reply, use the web interface found at > http://bugs.php.net/?id=10092&edit=2 -- IceWarp Software E-mail: info@icewarp.com Web: http://www.icewarp.com Fax: +1(240)5254912 ICQ: 1255673

« previous php.dev (#51881) next »