curl / Mailing Lists / curl-library / Single Mail
Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Random "couldn't resolve host" failures in curl_multi

From: Sinus via curl-library <curl-library_at_cool.haxx.se>
Date: Sun, 01 Sep 2019 10:52:13 +0200

Hello!

I'm experiencing a pretty random failure of curl_multi to grab some of
the handles added to it.

I create 12 handles for http:// URLs, all using the same target machine,
just different files. I add them to curl_multi. And as soon as I
curl_multi_exec, sometimes they all work, and sometimes only exactly
first 8 get fetched, others don't even show up in curl_multi_select
active count.

After making a proper error-checking setup with curl_multi_info_read, I
found that some of the handles get a "couldn't resolve host name"
message queued, right on the very first call to curl_multi_exec.
However, the error is not recorded in the child handles - the failed
ones return 0 for curl_errno.

Also, it's always the final handles that fail - n first handles work,
n+1 till the end fail to resolve, with n sometimes being all 12,
sometimes 8, a few times 4, but I also caught it on 11.

This is in cURL 7.62 under PHP 7.2.21.

Pseudocode to illustrate this would go:

m = curl_multi_init()
for i = 1 to 12 {
     handles[i] = curl_init ("http://the.same.host.com/file" + i)
     curl_multi_add_handle (m, handles[i])
}
status = curl_multi_exec (m, still_running) // status is 0,
still_running is 8, because...
info = curl_multi_info_read (m, queue) // info contains "couldn't
resolve host" for handle 9, queue shows 3 as there are also failures for
10, 11 and 12
keep_calling_curl_multi_exec_and_select_as_usual() //
error = curl_errno (handle[9]) // error is 0
info = curl_getinfo (handle[9]) // pretty much empty structure,
basically all 0s

So here are my 2 questions:
- what could be causing this to happen randomly?
- why isn't the error stored in the child handle?

Regards,

-- 
Adam "Sinus" SkawiƄski
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html
Received on 2019-09-01