php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #79318 curl_errno() is always 0 if there was an error while used with curl_multi()
Submitted: 2020-02-28 21:15 UTC Modified: -
From: work at christoph-kluge dot eu Assigned:
Status: Open Package: cURL related
PHP Version: 7.3.15 OS:
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: work at christoph-kluge dot eu
New email:
PHP Version: OS:

 

 [2020-02-28 21:15 UTC] work at christoph-kluge dot eu
Description:
------------
I was wondering why curl_errno() returned a 0 while beeing using with a curl_multi_init(). Not sure if this is a bug or if it's a documentation issue so I stated it first as an documentation issue.

It seems that the error is not populated into the resource. Only when I call curl_multi_info_read() then it gets populated into the resource.

References:

* https://bugs.php.net/bug.php?id=60660
* https://bugs.php.net/bug.php?id=33570
* https://bugs.php.net/bug.php?id=48304

Test script:
---------------
$handles = [];
$urls = [
    'https://www.google.com?v1',
    'https://wwwgooglecom?v2',
    'https://www.google.com?v3',
];

$mh = curl_multi_init();
foreach ($urls as $key => $value) {
    $handles[$key] = curl_init($value);
    curl_setopt($handles[$key], CURLOPT_HEADER, true);
    curl_setopt($handles[$key], CURLOPT_TIMEOUT, 10);
    curl_setopt($handles[$key], CURLOPT_RETURNTRANSFER, true);
    curl_multi_add_handle($mh, $handles[$key]);
}

do {
    $status = curl_multi_exec($mh, $running);
    curl_multi_select($mh);
} while ($running > 0 && $status === CURLM_OK);

// while ($result = curl_multi_info_read($mh)) {} // <<< uncomment this will give you the expected result

foreach($handles as $ch) {
    echo "Handle: " . curl_errno($ch) . PHP_EOL;
}

Expected result:
----------------
$ php test.php 
Result: (0) 
Result: (6) Could not resolve: wwwgooglecom (Domain name not found)
Result: (0) 


Actual result:
--------------
$ php test.php 
Result: (0) 
Result: (0) 
Result: (0)

Patches

Add a Patch

Pull Requests

Add a Pull Request

 
PHP Copyright © 2001-2020 The PHP Group
All rights reserved.
Last updated: Fri Nov 27 15:01:23 2020 UTC