cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: sharing DNS

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

-----BEGIN PGP SIGNED MESSAGE-----
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++
(http://www.sourceforge.net/projects/curlpp)
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)

iD8DBQE+JtA/b/24YeGNKWQRAi2gAKCgQGMMop0Pr6k+abB2ZEOkCWHmcACfav5L
L6V2XWfG1vkdNQ+E9EO9Hy8=
=CfKH
-----END PGP SIGNATURE-----

-------------------------------------------------------
This SF.NET email is sponsored by: Thawte.com
Understand how to protect your customers personal information by implementing
SSL on your Apache Web Server. Click here to get our FREE Thawte Apache
Guide: http://ads.sourceforge.net/cgi-bin/redirect.pl?thaw0029en
Received on 2003-01-16