curl / Mailing Lists / curl-library / Single Mail


Re: Frequent calls of CURLMOPT_TIMERFUNCTION with Multi Interface

From: Daniel Stenberg via curl-library <>
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:

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

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.

Received on 2019-03-26