From:             php at bouchery dot fr
Operating system: Windows XP & Debian
PHP version:      5.2.9
PHP Bug Type:     Streams related
Bug description:  http stream timeout is doubled

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 bug report at http://bugs.php.net/?id=48280&edit=1
-- 
Try a CVS snapshot (PHP 5.2):        
http://bugs.php.net/fix.php?id=48280&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):        
http://bugs.php.net/fix.php?id=48280&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):        
http://bugs.php.net/fix.php?id=48280&r=trysnapshot60
Fixed in CVS:                        
http://bugs.php.net/fix.php?id=48280&r=fixedcvs
Fixed in CVS and need be documented: 
http://bugs.php.net/fix.php?id=48280&r=needdocs
Fixed in release:                    
http://bugs.php.net/fix.php?id=48280&r=alreadyfixed
Need backtrace:                      
http://bugs.php.net/fix.php?id=48280&r=needtrace
Need Reproduce Script:               
http://bugs.php.net/fix.php?id=48280&r=needscript
Try newer version:                   
http://bugs.php.net/fix.php?id=48280&r=oldversion
Not developer issue:                 
http://bugs.php.net/fix.php?id=48280&r=support
Expected behavior:                   
http://bugs.php.net/fix.php?id=48280&r=notwrong
Not enough info:                     
http://bugs.php.net/fix.php?id=48280&r=notenoughinfo
Submitted twice:                     
http://bugs.php.net/fix.php?id=48280&r=submittedtwice
register_globals:                    
http://bugs.php.net/fix.php?id=48280&r=globals
PHP 4 support discontinued:          http://bugs.php.net/fix.php?id=48280&r=php4
Daylight Savings:                    http://bugs.php.net/fix.php?id=48280&r=dst
IIS Stability:                       
http://bugs.php.net/fix.php?id=48280&r=isapi
Install GNU Sed:                     
http://bugs.php.net/fix.php?id=48280&r=gnused
Floating point limitations:          
http://bugs.php.net/fix.php?id=48280&r=float
No Zend Extensions:                  
http://bugs.php.net/fix.php?id=48280&r=nozend
MySQL Configuration Error:           
http://bugs.php.net/fix.php?id=48280&r=mysqlcfg

Reply via email to