#17774 [Com]: connection_status() not returning correct result
| From: | neil dot doody at talk21 dot com | Date: | Wed, 25 Sep 2002 13:31:31 +0000 |
| Subject: | #17774 [Com]: connection_status() not returning correct result | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-20302@lists.php.net to get a copy of this message | ||
ID: 17774
Comment by: neil.doody@talk21.com
Reported By: neil@mpfreescene.com
Status: Open
Bug Type: Scripting Engine problem
Operating System: FREEBSD 4.5-STABLE
PHP Version: 4.0CVS-2002-06-15
New Comment:
I found there may be flaws with that code, so I wrote something else to
test if the function was fixed, and it appears not, here is the code,
if somebody cancels I would expect it to put '0' into wank.txt :-
<?
function exitfp() {
$fp = fopen("wank.txt","w");
fputs($fp, connection_status());
fclose($fp);
}
register_shutdown_function('exitfp');
if(connection_aborted() != true){print "0";}
flush();
ignore_user_abort(true);
$m = '50';
while(connection_aborted() != true and $m > $a){
sleep('1');
print connection_status();
flush();
$a = $a + 1;
}
exitfp();
?>
Previous Comments:
------------------------------------------------------------------------
[2002-09-25 07:38:18] neil.doody@talk21.com
According to Bug #17265 this problem should be fixed rite?
Well I downloaded the latest CVS like 5 minutes ago.
THe following code snippets should return into a file that the
connection was aborted, if this function was really fixed, rite?? well
the outputs I am getting into my temp files to check the output of the
script is "6077440 - 6076648 - 0 - not aborted - Keep-Alive"
Heres the script :-
while(!feof($pl_of) and !connection_aborted()) {
$pl_buffer = fread($pl_of, 1024);
echo($pl_buffer);
flush();
$pl_sent = $pl_sent + 1024;
}
fclose ($pl_of);
if ($pl_sent >= $pl_filesize){
$pl_totalsent = "100%";
}else{
$pl_totalsent = round((100 / $pl_filesize *
$pl_sent),2) . "%";
}
if (connection_aborted() == true){
$temp = 'aborted';
}else{
$temp = 'not aborted';
}
$pl_totalsent = "$pl_sent - $pl_filesize - " .
connection_status() . " -
" . $temp . " - " . $_SERVER['HTTP_CONNECTION'];
------------------------------------------------------------------------
[2002-07-07 13:10:32] david@hexstream.f9.co.uk
Has this bug been looked in to at all?
Under FreeBSD, connection_status /always/ returns 0.
I've never tried it with any other flavours of BSD.
Regards,
David.
------------------------------------------------------------------------
[2002-06-29 20:52:35] neil@mpfreescene.com
Just thought id enquire a little about this Bug, has it been a bug fora
long time? Do you think it will be sorted any time soon ?
Do you think we may see it repaired for PHP 4.3.0-STABLE ?
------------------------------------------------------------------------
[2002-06-15 19:51:50] sniper@php.net
There's already some reports about this. But it's nice to have
another.
------------------------------------------------------------------------
[2002-06-15 16:37:11] neil@mpfreescene.com
Im runnig PHP 4.3.0CVS on Apache 2.x
My problem is that I have written a script that sends
content-dispostion headers to the browser and starts a download.
When they user cancels the downloads, connection_status() is not
reflecting this. I would assume that it shuold return a value of 1,
USER ABORTED.
Instead the script continues to run in the background by sending the
file somewhere (limbo?). The script then reaches the end and
terminates normally.
After the script has terminated normally the value for
connection_status() is still set at 0 NORMAL.
Ive registered a shutdown function and tried all different methods like
connection_aborted() which is FALSE, ive set ignore_user_abort() to
TRUE and FALSE, but still alwasy the same result.
A problem arrises that it is entering false information to my weblogs,
i.e. its saying that the entire file was transferred when indeed it was
canceled half way through.
Im reading the file with fread() in 1K chunks and flushing in between,
so as the script does not buffer everything and terminate prematurly,
this is verified by the dump I have constructed at the end of the
script to tell me what connection_status() is saying, which doesnt get
written until you press to cancel the download or complete the
download, so the script is definatly midway in progress at that time.
Ive read in teh user contributed notes of somebody else expierencing
the same problem as me, that was back in FEB-2002. The hack he has
written to use netstat is far to resource intensive.
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=17774&edit=1