php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #60660 curl_errno returns 0 instead of 6
Submitted: 2012-01-04 21:16 UTC Modified: 2012-01-06 16:19 UTC
Votes:2
Avg. Score:3.5 ± 0.5
Reproduced:2 of 2 (100.0%)
Same Version:1 (50.0%)
Same OS:1 (50.0%)
From: bart at ajaxer dot net Assigned:
Status: Not a bug Package: cURL related
PHP Version: 5.3.8 OS: Win XP
Private report: No CVE-ID: None
 [2012-01-04 21:16 UTC] bart at ajaxer dot net
Description:
------------
This issue concerns only multi curl.

Single handle curl works correct and returns error no. 6 when host is not resolved.

In the same situation multi curl returns 0 with curl_errno function despite the fact that curl_error returns error message.

See codes of 2 examples below

Test script:
---------------
<?
// Create a curl handle to a non-existing location
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://osms.pl');

// Execute
curl_exec($ch);

// Check if any error occured
if(curl_errno($ch))
{
    echo 'Curl error: ' . curl_error($ch) . ' - ' .curl_errno($ch);
}

// Close handle
curl_close($ch);
?>

-------------------------------------------------------------------------------

<?php
// create both cURL resources
$ch1 = curl_init();

// set URL 
curl_setopt($ch1, CURLOPT_URL, "http://404.php.net/");


//create the multiple cURL handle
$mh = curl_multi_init();

curl_multi_add_handle($mh,$ch1);

$active = null;
//execute the handles
do {
    $mrc = curl_multi_exec($mh, $active);
} while ($mrc == CURLM_CALL_MULTI_PERFORM);

while ($active && $mrc == CURLM_OK) {
    if (curl_multi_select($mh) != -1) {
        do {
            $mrc = curl_multi_exec($mh, $active);
        } while ($mrc == CURLM_CALL_MULTI_PERFORM);
    }
}

echo 'Curl error: ' . curl_error($ch1) . ' - ' .curl_errno($ch1);


//close the handles
curl_multi_remove_handle($mh, $ch1);
curl_multi_close($mh);
?>


Expected result:
----------------
in first example:
Curl error: Could not resolve host: osms.pl; Host not found - 6

in second:
Curl error: Could not resolve host: (nil); Host not found - 0



Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2012-01-06 16:19 UTC] pierrick@php.net
-Status: Open +Status: Bogus
 [2012-01-06 16:19 UTC] pierrick@php.net
Thank you for taking the time to write to us, but this is not
a bug. Please double-check the documentation available at
http://www.php.net/manual/ and the instructions on how to report
a bug at http://bugs.php.net/how-to-report.php

If you're using curl_multi_exec you need to use curl_multi_info_read to get the 
curl error code
 [2012-02-24 05:04 UTC] cem at namekan dot org
This bug is still not fixed
 
PHP Copyright © 2001-2019 The PHP Group
All rights reserved.
Last updated: Tue Nov 19 20:01:37 2019 UTC