Bug #77929 [Com]: curl on phpfpm ignore max execution time, time limit and ignore_user_abort
| From: | spam2 at rhsoft dot net | Date: | Sun, 21 Apr 2019 10:03:50 +0000 |
| Subject: | Bug #77929 [Com]: curl on phpfpm ignore max execution time, time limit and ignore_user_abort | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-220549@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=77929&edit=1
ID: 77929
Comment by: spam2 at rhsoft dot net
Reported by: ghislain at ghislain dot net
Summary: curl on phpfpm ignore max execution time, time limit
and ignore_user_abort
Status: Open
Type: Bug
Package: PHP options/info functions
Operating System: debian8
PHP Version: 7.2.17
Block user comment: N
Private report: N
New Comment:
max_execution_time and "curl extention should not be able to bypass general php
safeguards" - well, the url stuff runs in libcurl and PHP has no saying about that and
can't measure things running outside the zendengine
max_execution_time is about computing time!
Previous Comments:
------------------------------------------------------------------------
[2019-04-21 08:39:38] ghislain at ghislain dot net
Description:
------------
hi,
PHP Version 7.2.17-1+0~20190412070953.20+jessie~1.gbp23a36d
System Linux 4.9.168-vs2.3.9.8aq #1 SMP Tue Apr 9 13:28:31 CEST 2019 x86_64
when using curl_exec on an url that do not answer on php7.2 fpm, the php fpm process can stay open
forever if some curl timeout is not set. This means that curl is bypassing all php internal timeout
like
set_time_limit
max_execution_time
default_socket_timeout
and even ignore_user_abort.
The only way is to add curl specific time out
//curl_setopt($ch, CURLOPT_TIMEOUT, 10);
//curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl extention should not be able to bypass general php safeguards.
best regards,
Ghislain
Test script:
---------------
<?php
echo date('l jS \of F Y h:i:s A');
// Création d'une nouvelle ressource cURL
$ch = curl_init();
set_time_limit ( 10 ) ;
# Make sure to keep alive the script when a client disconnect.
ignore_user_abort(false);
// Configuration de l'URL et d'autres options
curl_setopt($ch, CURLOPT_URL, "http://myserver.com/curltest.php");
curl_setopt($ch, CURLOPT_HEADER, 0);
//curl_setopt($ch, CURLOPT_TIMEOUT, 10);
//curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
if(curl_exec($ch) === false)
{
echo 'Erreur Curl : ' . curl_error($ch);
}
else
{
echo 'L\'opération s\'est terminée sans aucune erreur';
}
// Fermeture de la session cURL
curl_close($ch);
echo date('l jS \of F Y h:i:s A');
?>
+http://myserver.com/curltest.php =
<?php
sleep( 12000);
?>
Expected result:
----------------
script should stop at 10s or at max execution time.
Actual result:
--------------
stay on until a php-fpm restart
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=77929&edit=1