curl / Mailing Lists / curl-library / Single Mail

curl-library

Re: Frequent calls of CURLMOPT_TIMERFUNCTION with Multi Interface

From: Daniel Stenberg via curl-library <curl-library_at_cool.haxx.se>
Date: Tue, 26 Mar 2019 09:00:41 +0100 (CET)

On Tue, 26 Mar 2019, Nick Kostirya via curl-library wrote:

> I found that CURLMOPT_TIMERFUNCTION callback is often called with 0 value.
> This happens when resolver thread is working. What for?

Because of lame internal reasons! :-/

I presume your libcurl is built with the threaded resolver.

The threaded resolver thread offers no file descriptor for the main thread to
wait for, to figure out when the resolving is complete, so it has to just
repeatedly poll. And what if the resolve is completely really fast?

It has a slowly increasing timeout timer but in order to repond quickly for
the really fast lookups (that tend to be frequent and important), it uses zero
for the first three milliseconds. See the logic here:

https://github.com/curl/curl/blob/f5bc578f4cdfdc6c708211dfc2962a0e9d79352d/lib/asyn-thread.c#L594-L615

I'm open for suggestions and improvements there. This is a pretty crude
approach.

Ideally each resolver thread would have a pipe to signal back the
"completeness" state back over so that the main thread wouldn't have to poll
at all.

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette:   https://curl.haxx.se/mail/etiquette.html
Received on 2019-03-26