Bug #72060 [NEW]: use curl_multi_*, curl_errno return data not expect
| From: | 568089266 at qq dot com | Date: | Wed, 20 Apr 2016 02:55:03 +0000 |
| Subject: | Bug #72060 [NEW]: use curl_multi_*, curl_errno return data not expect | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-200655@lists.php.net to get a copy of this message | ||
From: 568089266 at qq dot com
Operating system: Osx EI 10.11.4
PHP version: 5.5.34
Package: cURL related
Bug Type: Bug
Bug description:use curl_multi_*, curl_errno return data not expect
Description:
------------
php version 5.5.32
curl 7.37.0 (x86_64-apple-darwin13.0.2) libcurl/7.37.0 OpenSSL/0.9.8}
zlib/1.2.5
I found use curl_multi_* methods, if some curl handle connect fail or
execute timeout, use curl_errno function to get the error code, but
alway return zero. curl_error function return data is right;
Test script:
---------------
<?php
//example 1
$mh = curl_multi_init();
$ch1 = curl_init('http://www.some_not_exist_host.com');
curl_setopt($ch1, CURLOPT_TIMEOUT, 3);
curl_setopt($ch1, CURLOPT_CONNECTTIMEOUT_MS, 400);
curl_setopt($ch1, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch1, CURLOPT_NOSIGNAL, true);
curl_multi_add_handle($mh, $ch1);
$ch2 = curl_init('http://127.0.0.1');
curl_setopt($ch2, CURLOPT_TIMEOUT, 3);
curl_setopt($ch2, CURLOPT_CONNECTTIMEOUT_MS, 400);
curl_setopt($ch2, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch2, CURLOPT_NOSIGNAL, true);
curl_multi_add_handle($mh, $ch2);
$active = null;
do{
do {
$mrc = curl_multi_exec($mh, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);
if ($mrc != CURLM_OK){
break;
}
$info = curl_multi_info_read($mh, $msgs_in_queue);
if ($info !== false){
$ch = $info['handle'];
var_dump(curl_error($ch));
var_dump(curl_errno($ch)); //bug? alway return 0
curl_multi_remove_handle($mh, $ch);
}
if ($active > 0) {
curl_multi_select($mh, 0.5);
}
}while ($active);
curl_multi_remove_handle($mh, $ch1);
curl_multi_close($mh);
//example 2
echo "----------------", PHP_EOL;
$ch = curl_init('http://www.some_not_exist_host.com');
curl_setopt($ch, CURLOPT_TIMEOUT, 3);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT_MS, 400);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch, CURLOPT_NOSIGNAL, true);
curl_exec($ch);
var_dump(curl_error($ch));
var_dump(curl_errno($ch));
Expected result:
----------------
string(0) ""
int(0)
string(51) "Could not resolve host: www.some_not_exist_host.com"
int(6)
----------------
string(51) "Could not resolve host: www.some_not_exist_host.com"
int(6)
Actual result:
--------------
string(0) ""
int(0)
string(51) "Could not resolve host: www.some_not_exist_host.com"
int(0)
----------------
string(51) "Could not resolve host: www.some_not_exist_host.com"
int(6)
--
Edit bug report at https://bugs.php.net/bug.php?id=72060&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=72060&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=72060&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=72060&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=72060&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=72060&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=72060&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=72060&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=72060&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=72060&r=support
Expected behavior: https://bugs.php.net/fix.php?id=72060&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=72060&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=72060&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=72060&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=72060&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=72060&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=72060&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=72060&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=72060&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=72060&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=72060&r=mysqlcfg