|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2003-02-28 06:34 UTC] 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===($a=@fsockopen("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.
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 10:00:02 2025 UTC |
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.