Doc #79318 [Com]: curl_errno() is always 0 if there was an error while used with curl_multi()

From: Date: Thu, 21 Jan 2021 04:56:27 +0000
Subject: Doc #79318 [Com]: curl_errno() is always 0 if there was an error while used with curl_multi()
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-18431@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=79318&edit=1

 ID:                 79318
 Comment by:         sheilafox198678 at gmail dot com
 Reported by:        work at christoph-kluge dot eu
 Summary:            curl_errno() is always 0 if there was an error while
                     used with curl_multi()
 Status:             Open
 Type:               Documentation Problem
 Package:            cURL related
 PHP Version:        7.3.15
 Block user comment: N
 Private report:     N

 New Comment:

Returns the error number or 0 (zero) if no error occurred. using curl_multi_info_read() in the
curl_multi_exec() loop that don't show up later using curl_errno().



https://www.noxappplayer.org/


Previous Comments:
------------------------------------------------------------------------
[2020-02-28 21:15:04] 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)


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



--
Edit this bug report at https://bugs.php.net/bug.php?id=79318&edit=1


Thread (2 messages)

« previous php.doc.bugs (#18431) next »