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
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: bart at ajaxer dot net
New email:
PHP Version: OS:

 

 [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
 [2021-09-27 23:59 UTC] michael dot vorisek at email dot cz
Please help fixing this bug. The issue is present when curl_multi is used and curl_errno($ch, ...) should be supported.

Currently, there is no way of identifying failures (not trusted certificate, connection timeout, ...) when curl_multi is used.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 11:01:29 2024 UTC