On Tue, 16 Jul 2019, Amit wrote:

I don't actually advocate using 100ms all the time. It needs to be shorter at first and then increase over time. curl_multi_timeout() return such timeouts.

Thanks, will use curl_multi_timeout() instead of fixed 100 msec
timer.

Just note that curl_multi_timeout() only started to return those suitable timeouts during the threaded name resolver in 7.60.0, so in earlier versions you need to do that yourself.

why do you think notifying DNS-completed in resolver thread is a bad idea ?

Because it would be surprising to applications (since no callbacks in libcurl is ever called from another thread) and introduce the typical threading issues requiring mutexes, locks etc and risk causing race conditions in the app.

Anyways, application would be handling that DNS-completed event in CURL thread context.

If you call libcurl from thread A and the callback comes from thread B (that curl itself created), then surely those are not using the same thread contexts?

The *better* fix would be to instead use a pipe/sockpair to signal that the name resolve is complete and then have the application be able to wait on that.

Are you suggesting that let CURL internally create pipe/socket pair for DNS resolution and application wait on the same fd ?

I'm suggesting that would be one way to offer a solution.

And on DNS resolution, CURL will write to the pipe, which will cause application thread to wake up and application can trigger the CURL to resume the connection ?

Correct.

Regarding your concern on Windows, I am not sure about the CURL development process, but since I am working on linux, would like to know if It if okay to implement it only for linux ? If you are fine, then I can explore more in this direction.

Sure, a solution that only works for non-Windows is totally fine, as Windows users could then either just remain the current method or a Windows developer could work on providing the corresponding solution for that platform.

--

 / daniel.haxx.se | Get the best commercial curl support there is - from me
                  | Private help, bug fixes, support, ports, new features
                  | https://www.wolfssl.com/contact/
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html

Reply via email to