From:             ukrtelecom at gmail dot com
Operating system: Linux
PHP version:      5.4Git-2013-08-30 (snap)
Package:          *General Issues
Bug Type:         Bug
Bug description:usleep prevents script timeout

Description:
------------
Usleeped time does not count in total timeout time.

Commenting out line 11 "usleep(10)" in the test script results with
expected 
Fatal timeout in 2 seconds.
Enabling line 11 "usleep(10)" makes script exit by condition in 50
seconds.
Increasing waiting time to 100 seconds in line 2 results with timeout Fatal

error in 60-70 sec.


PHP 5.4.20-dev (cli) (built: Aug 30 2013 14:18:16) 
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies

./configure --disable-libxml --disable-xml --disable-simplexml --disable-
xmlreader --disable-xmlwriter --disable-dom --without-pear

OS Ubuntu 12.04 LTS 
Linux precise64 3.2.0-23-generic #36-Ubuntu SMP Tue Apr 10 20:39:51 UTC
2012 
x86_64 x86_64 x86_64 GNU/Linux

Test script:
---------------
<?php
$wait = 50;

echo ini_get('max_execution_time');

set_time_limit(2);

$ts = time();
while(true) {
        // usleep for 10 microseconds
        usleep(10);
        if ((time()- $ts) > $wait) {
                echo time() -$ts;
                echo "\n\nFailed! " . ini_get('max_execution_time') . "\n";
                break;
        }
}



Expected result:
----------------
0
Fatal error: Maximum execution time of 2 seconds exceeded in
/home/vagrant/t.php 
on line 12

Actual result:
--------------
#with wait time 50 sec:
$ date; php t.php ; date
Fri Aug 30 15:40:54 UTC 2013
0
51

Failed! 2
Fri Aug 30 15:41:45 UTC 2013


#with wait time 100 sec:
$ date; php t.php ; date
Fri Aug 30 15:35:45 UTC 2013
0

Fatal error: Maximum execution time of 2 seconds exceeded in
/home/vagrant/t.php 
on line 12
Fri Aug 30 15:36:40 UTC 2013


-- 
Edit bug report at https://bugs.php.net/bug.php?id=65596&edit=1
-- 
Try a snapshot (PHP 5.4):   
https://bugs.php.net/fix.php?id=65596&r=trysnapshot54
Try a snapshot (PHP 5.3):   
https://bugs.php.net/fix.php?id=65596&r=trysnapshot53
Try a snapshot (trunk):     
https://bugs.php.net/fix.php?id=65596&r=trysnapshottrunk
Fixed in SVN:               https://bugs.php.net/fix.php?id=65596&r=fixed
Fixed in release:           https://bugs.php.net/fix.php?id=65596&r=alreadyfixed
Need backtrace:             https://bugs.php.net/fix.php?id=65596&r=needtrace
Need Reproduce Script:      https://bugs.php.net/fix.php?id=65596&r=needscript
Try newer version:          https://bugs.php.net/fix.php?id=65596&r=oldversion
Not developer issue:        https://bugs.php.net/fix.php?id=65596&r=support
Expected behavior:          https://bugs.php.net/fix.php?id=65596&r=notwrong
Not enough info:            
https://bugs.php.net/fix.php?id=65596&r=notenoughinfo
Submitted twice:            
https://bugs.php.net/fix.php?id=65596&r=submittedtwice
register_globals:           https://bugs.php.net/fix.php?id=65596&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=65596&r=php4
Daylight Savings:           https://bugs.php.net/fix.php?id=65596&r=dst
IIS Stability:              https://bugs.php.net/fix.php?id=65596&r=isapi
Install GNU Sed:            https://bugs.php.net/fix.php?id=65596&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=65596&r=float
No Zend Extensions:         https://bugs.php.net/fix.php?id=65596&r=nozend
MySQL Configuration Error:  https://bugs.php.net/fix.php?id=65596&r=mysqlcfg

Reply via email to