#48280 [Opn->Fbk]: http stream timeout is doubled
| From: | jani@php.net | Date: | Tue, 22 Dec 2009 10:03:52 +0000 |
| Subject: | #48280 [Opn->Fbk]: http stream timeout is doubled | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-146025@lists.php.net to get a copy of this message | ||
ID: 48280
Updated by: jani@php.net
Reported By: php at bouchery dot fr
-Status: Open
+Status: Feedback
Bug Type: Streams related
Operating System: *
PHP Version: 5.2.9
New Comment:
Please try using this snapshot:
http://snaps.php.net/php5.2-latest.tar.gz
For Windows:
http://windows.php.net/snapshots/
Previous Comments:
------------------------------------------------------------------------
[2009-05-20 13:29:13] php at bouchery dot fr
I did it on localhost and on a remote machine:
sleep-flush.php
<?php
echo 'start';
flush();
sleep(20);
echo 'sleep';
?>
sleep.php
<?php
sleep(20);
echo 'sleep';
?>
------------------------------------------------------------------------
[2009-05-20 12:59:15] jani@php.net
And where are the sources for those server side scripts?
------------------------------------------------------------------------
[2009-05-14 11:59:39] php at bouchery dot fr
Description:
------------
When I perform a HTTP timeout using "stream_context_create",
"stream_set_timeout" or "default_socket_timeout", timeout is doubled.
I did it on :
- Windows XP SP2 + PHP-Cli 5.1.6
- Windows XP SP2 + PHP-Cli 5.2.9-2
- Debian 5 + PHP 5.2.0-8+etch13 (cli)
Reproduce code:
---------------
<?php
$time = time();
// sleep-flush.php flush a text before sleeping 20 seconds
$f = @fopen('http://localhost/sleep-flush.php',
'r');
if( $f !== false ) {
stream_set_timeout($f, 2);
$content = stream_get_contents( $f );
fclose($f);
}
echo 'Code #1: Duration = ', (time() - $time), "\n";
$context = stream_context_create(array('http' => array('timeout' =>
3)));
$time = time();
// sleep do not flush text before sleeping 20 seconds
$f = @fopen('http://localhost/sleep.php',
'r', false, $context);
if( $f !== false ) {
$content = stream_get_contents( $f );
fclose($f);
}
echo 'Code #2: Duration = ', (time() - $time), "\n";
ini_set('default_socket_timeout', '4');
$time = time();
// sleep do not flush text before sleeping 20 seconds
$f = @fopen('http://localhost/sleep.php',
'r');
if( $f !== false ) {
$content = stream_get_contents( $f );
fclose($f);
}
echo 'Code #3: Duration = ', (time() - $time), "\n";
?>
Expected result:
----------------
Code #1: Duration = 2
Code #2: Duration = 3
Code #3: Duration = 4
Actual result:
--------------
Code #1: Duration = 4
Code #2: Duration = 6
Code #3: Duration = 8
------------------------------------------------------------------------
--
Edit this bug report at http://bugs.php.net/?id=48280&edit=1