Re: synchronous i/o code inside of curl_easy_init() using c-ares

2018-02-05 Thread Daniel Stenberg

On Fri, 2 Feb 2018, Василий Куликов wrote:

So, when I try to create easy handle and use it in async way, ares still 
does pretty much synchronous actions. AFAICS, there is no option to disable 
re-reading of /etc/resolv.conf, /etc/hosts, etc.


Is it a deliberate decision to read these files synchronously?  Is it 
possible to use c-ares in libcurl and not to do any sync i/o in a client 
thread?


c-ares is a separate project with a separate mailing list[1] and issue 
tracker[2].


However, the fact is that reading files isn't really doable asynchronously in 
a portable manner, so I figure the best approach here is probably to control 
the behavior more with options. Although that brings the problem with when/how 
those files should be read...


Certainly something to take to c-ares for discussion!

[1] = https://cool.haxx.se/mailman/listinfo/c-ares
[2] = https://github.com/c-ares/c-ares/issues

--

 / daniel.haxx.se---
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html

synchronous i/o code inside of curl_easy_init() using c-ares

2018-02-02 Thread Василий Куликов
Hi!

We use libcurl in a project to handle >10K HTTP requests/second using multi 
interface via curl-asio C++ wrapper (https://github.com/mologie/curl-asio). If 
default threaded DNS resolver is used, curl_easy_init() is very fast; however, 
if I switch to c-ares, curl_easy_init() stucks in reading local files inside of 
ares_init_options().

An example stack trace is as following:


0 read () at ../sysdeps/unix/syscall-template.S:81
1 _IO_new_file_underflow (fp=0x7f05bc1e4060) at fileops.c:613
2 __GI__IO_file_xsgetn (fp=0x7f05bc1e4060, data=, n=31) at 
fileops.c:1418
3 __GI__IO_fread (buf=, size=1, count=31, fp=0x7f05bc1e4060) at 
iofread.c:42
4 ares_init_options ()
5 Curl_resolver_init ()
6 Curl_open ()
7 curl_easy_init ()
8 curl::easy::init (this=0x7f05bc1e3f28) +504
9 curl::easy::easy (this=0x7f05bc1e3f28, multi_handle=...) +36

So, when I try to create easy handle and use it in async way, ares still does 
pretty much synchronous actions.
AFAICS, there is no option to disable re-reading of /etc/resolv.conf, 
/etc/hosts, etc.

Is it a deliberate decision to read these files synchronously?  Is it possible 
to use c-ares in libcurl and not to do any sync i/o in a client thread?
---
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html