ID: 22474
Updated by: [EMAIL PROTECTED]
Reported By: chuck at fuck dot org
-Status: Open
+Status: Feedback
Bug Type: Filesystem function related
Operating System: FreeBSD 4.7
PHP Version: 5CVS-2003-02-28 (dev)
New Comment:
Can you provide a bit more information?
I want to see a script like this:
<?php
$fp = fsockopen($host, $port, $err, $errstr, 10);
if (!$fp) {
die("Connection failed: $err $errstr);
}
stream_set_timeout($fp, 15);
$n = fwrite($fp, "data");
var_dump($n);
fclose($fp);
?>
But please fill in the $host and $port with addresses that I can use
from my machine(s) so that I can try and replicate.
Alternatively, please read the docs here
http://bugs.php.net/bugs-generating-backtrace.php
and generate a backtrace from within the fwrite() when it is eating up
the cpu:
Compile php with --enable-debug first then:
gdb ./sapi/cli/php
run myscript.php
[ wait for it to "hang" ]
[ press CTRL-C ]
bt full
Please post the backtrace at a URL and enter the link into this
report.
If you can provide a reproducing script AND a backtrace, that is even
more useful.
Previous Comments:
------------------------------------------------------------------------
[2003-02-28 06:34:23] chuck at fuck dot org
When using a fsockopen resource that has been accepted, but is
non-responsive, fwrite will use as much cpu as it can before the
program is terminated by the time limit.
if(false===([EMAIL PROTECTED]("tcp://$a", 1080, $err, $errstr, 10)))
return false;
$conn=pack('ccnN', '4', 1, 25, ip2long($ip)) .pack('a',$socksusers);
stream_set_timeout($a, 15);
if(!socks_write($a,$conn,9)) return false;
function socks_write(&$a,$b,$c=false) {
$tmp=fwrite($a,$b,$c);
if($c != $tmp) return false;
return true;
}
This program will freeze at the fwrite command.
I've had this happen on PHP 4.3.0 and CVS
It only occurs when specific servers are addressed in the fsockopen.
While I understand the server may be responding with garbage data, the
fsockopen should not be returning the connection as success. Even with
that case, I don't see reason for the fwrite to hang with high cpu
usage.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=22474&edit=1