cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Threaded resolver still blocked in Curl_resolver_cancel?

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Tue, 1 May 2012 22:02:37 +0200 (CEST)

On Tue, 1 May 2012, Mac Wang wrote:

> So I guess Curl_expire doesn't do anything if not used in multi interface
> (?)

That is correct. But that expire time is not used for anything with the easy
interface so it follows very clear logic. The threaded resolver still works!

> and finally blocks at here:
>
> Curl_thread_join(&td->thread_hnd);

...

> I guess it's totally understandable that a 'join' would block here, for the
> whole need for a threaded resolver is because the system resolver blocks. If
> we can have only one name resolver thread for each connection (is that so?),

Well, perhaps not. First, I could imagine to pass over ownership of the
resolver to the multi handle so that a single handle can still terminate while
the resolver thread hasn't yet died. Secondly, there doesn't *have to* be a
strict 1:1 relationship between easy handles and their name resolver threads
but changing this will require proper concentration and design so that it
still works correctly. After all, the resolver thread uses the stock resolver
functions and they are blocking and they may take a very long time so just
blindly re-using another thread for resolving will introduce other problems.
But of course, perhaps we can allow an easy handle to start a new resolver
thread before the previous one has completed...

Possibly we would even figure out that not using a dedicated thread for each
handle isn't really possibly while still maintaining the same level of
functionality.

> If we can have multiple threads and 'detach' them, we can potentially have
> multiple (blocked) resolver threads running while the main system continues.

Yes, I believe it would be possible. Don't count on *me* working on that very
much though. In my high volume use cases I've used the c-ares backend instead
to avoid those pesky threading quirks... I'll of course still help out with
design and review of any work anyone would be intersted in pushing forward
within this area.

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2012-05-01