cURL / Mailing Lists / curl-library / Single Mail


Re: sharing DNS

From: Jean-Philippe Barrette-LaPierre <>
Date: Thu, 16 Jan 2003 10:31:07 -0500

Hash: SHA1

Le Thursday 16 January 2003 07:56, Daniel Stenberg a écrit :
> On Wed, 15 Jan 2003, Jean-Philippe Barrette-LaPierre wrote:
> > I allmost finished the implementaion of the sharing DNS thing. However
> > there's missing thing to get thread-safe: a function that duplicate a
> > "Curl_dns_entry *".
> Eh. Why do we need to duplicate something that is shared?
> > The problem is with the hostcache_prune function, the function that clean
> > all outdated hostcache entry. At this time it's using the inuse variable,
> > but it's not thread-safe, so I'll need a dns_entry duplicate function.
> Now, please tell me why the 'inuse' struct field is not thread safe? As
> long as we access it while having the mutex, it should be perfectly OK. And
> then we can share the structs fine. Or am I wrong?
> > P.S. I don't have a deepfull knowledge of the addrinfo structure(to be
> > portable), so I can't do the duplicate function myself.
> We do not want to walk down that path. We simply must do it another way.

if you check Curl_resolv return a Curl_dns_entry *. The handle use this entry
to connect to the remote site. The problem is that entry is contained by the
global_dns_cache (if the handle use the global dns cache). In the Curl_resolv
thereis a function that delete the outdated entries. At this time the library
use inuse to verify that the entry is not used at the time we want to delete
it. The problem is that inuse is not thread-safe and I don't want to lock the
mutex until we doesn't use a dns entry anymore. It will cause a too big
bottleneck to do that. At this time the sharing this for the mutex is just
limited in the Curl_resolv, but if I need to lock the mutex until we don't
use the dns_entry, I'll need to put implement the sharing thing in others
functions that uses the dns_entry and that will be become very complicated,
and the performence cost (because of the bottleneck) will be mutch higher
that if we just copy the dns_entry.

- --
Jean-Philippe Barrette-LaPierre
Maintener of curlpp: When TRYING(but still in good way) to get the best of C++
Version: GnuPG v1.0.7 (GNU/Linux)


This SF.NET email is sponsored by:
Understand how to protect your customers personal information by implementing
SSL on your Apache Web Server. Click here to get our FREE Thawte Apache
Received on 2003-01-16