ID:               40895
 Updated by:       [EMAIL PROTECTED]
 Reported By:      allali at labri dot fr
-Status:           Open
+Status:           Bogus
 Bug Type:         Output Control
 Operating System: Linux
 PHP Version:      5.2.1
 New Comment:

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.




Previous Comments:
------------------------------------------------------------------------

[2007-03-22 17:21:16] allali at labri dot fr

Description:
------------
The problem is that I have a script which is called twice by the same
brother using a Http connection with the Keep Alive attibute.

For the first call: 

I notify the end of the answer as follow:
===========================================
ignore_user_abort(true);
$msg="toto";
header("Content-Length: ".strlen($msg));
echo $msg;
flush();
... some long time stuff here=
===========================================
the browser read the answer and then I ask again for the same page
using the same tcp connection (Keep-alive). 

In the second call, the output is blocked until the first call process
is dead. Thus its execution is suspended until the "long time stuff" is
done. (I see the http request using tcpdump). 



If I put the following for the first call:

====================================================
header("Cache-Control: no-cache, must-revalidate");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Connection: close");

$msg="toto";
header("Content-Length: ".strlen($msg));
echo $msg;
flush();
=====================================================

then all work fine except that the connection is effectively closed by
the browser and then re-open which implies a great lost of
performances.

Also I did not find any mechanism (bug?) in php to indicate that the
response is done. (like http_close or fclose(STDOUT) // STDOUT doesn't
exists...). Maybe, php is suppose to guess that using the Content-Length
(bug?).

Perhaps it is apache which is waiting for the end of the process or the
closing of the standard process output.

Finally, I think this become critical in AJAX aplications.

Thx
  J.A.

Reproduce code:
---------------
<? // hello.php
if (isset($_GET["a"])==false){
  ignore_user_abort(true);
  $msg="hello";
  header("Content-Length: ".strlen($msg));
  if (isset($_GET["close"])){ 
     header("Cache-Control: no-cache, must-revalidate");
     header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
     header("Connection: close");
  }
  echo $msg;
  flush();
  sleep(20);
}
else{
  echo "world!";
}
?>


Expected result:
----------------
just call the script twice:
hello.php 
=> hello
hello.php?a
=> world!
immediately

Actual result:
--------------
just call the script twice:
hello.php 
=> hello
hello.php?a
=> world!
after 20 seconds.


------------------------------------------------------------------------


-- 
Edit this bug report at http://bugs.php.net/?id=40895&edit=1

Reply via email to