Bug #77929 [NEW]: curl on phpfpm ignore max execution time, time limit and ignore_user_abort
| From: | ghislain at ghislain dot net | Date: | Sun, 21 Apr 2019 08:39:38 +0000 |
| Subject: | Bug #77929 [NEW]: curl on phpfpm ignore max execution time, time limit and ignore_user_abort | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-220546@lists.php.net to get a copy of this message | ||
From: ghislain at ghislain dot net
Operating system: debian8
PHP version: 7.2.17
Package: PHP options/info functions
Bug Type: Bug
Bug description:curl on phpfpm ignore max execution time, time limit and ignore_user_abort
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 bug report at https://bugs.php.net/bug.php?id=77929&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=77929&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=77929&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=77929&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=77929&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=77929&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=77929&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=77929&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=77929&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=77929&r=support
Expected behavior: https://bugs.php.net/fix.php?id=77929&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=77929&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=77929&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=77929&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=77929&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=77929&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=77929&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=77929&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=77929&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=77929&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=77929&r=mysqlcfg