Bug #65596 [Opn->Wfx]: usleep prevents script timeout
| From: | ab@php.net | Date: | Fri, 30 Aug 2013 18:00:25 +0000 |
| Subject: | Bug #65596 [Opn->Wfx]: usleep prevents script timeout | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-181368@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=65596&edit=1
ID: 65596
Updated by: ab@php.net
Reported by: ukrtelecom at gmail dot com
Summary: usleep prevents script timeout
-Status: Open
+Status: Wont fix
Type: Bug
Package: *General Issues
Operating System: Linux
PHP Version: 5.4Git-2013-08-30 (snap)
Block user comment: N
Private report: N
New Comment:
This is unsolvable in PHP, sleep is a system call so it will suspend the execution
. It can be only interrupted by a signal which can't be thrown from PHP because
the execution is suspended :)
Previous Comments:
------------------------------------------------------------------------
[2013-08-30 15:47:44] ukrtelecom at gmail dot com
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 this bug report at https://bugs.php.net/bug.php?id=65596&edit=1