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: -
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:1 (100.0%)
Same OS:1 (100.0%)
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
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
16 + 13 = ?
Subscribe to this entry?

 
 [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-2024 The PHP Group
All rights reserved.
Last updated: Sat Apr 20 01:01:28 2024 UTC