cURL
Haxx ad
libcurl

Shopping cart software, Online file storage, Online photo storage, Hosted shopping cart, Contact management software, Email marketing software, Project management software, Issue tracking software, Online notepad, Web publishing software

curl's project page on SourceForge.net

Sponsors:
Haxx

cURL > Mailing List > Monthly Index > Single Mail

curl-library Archives

Re: [PATCH, RFC] Make hostthre.c work on POSIX

From: Daniel Stenberg <daniel_at_haxx.se>
Date: Sun, 8 Nov 2009 20:03:37 +0100 (CET)

On Sat, 7 Nov 2009, Constantine Sapuntzakis wrote:

>> If a getaddrinfo() or a gethostbyname_r() implementation anywhere is
>> unsafe, we already should have problems since libcurl is claimed to be
>> thread-safe already when using those functions and it has used them for
>> many years without problems.
>
> That's assuming the client program is threaded. Perhaps on Unix, people
> mostly use curl in a single thread per process (curl executable, Apache).

I think single-threaded is the most common case, yes, but a large number of
users use libcurl multi-threaded in various ways. If the standard name
resolving ways we use wouldn't be thread-safe, our users would have suffered
and we have *never* seen it happen.

But it could also be a sign that users of multi-threaded libcurl are on
operating systems that do these things right.

> A gethostbyname_r() that's thread unsafe would be a horrible hack. I would
> hope such setups are exceedingly rare.

I'd claim that getaddrinfo() done thread unsafe is a horrible hack as well.
And in fact
http://www.opengroup.org/onlinepubs/009695399/functions/getaddrinfo.html
clearly states that:

   "The freeaddrinfo() and getaddrinfo() functions shall be thread-safe."

At least that means that such implementations aren't followin the spec - but
yeah I know, that doesn't help us much...

>> Can anyone mention a getaddrinfo() or a gethostbyname_r() implementation
>> that isn't thread-safe?
>
> In many of the BSDs getaddrinfo() was not thread safe.

Ugh! Hm. Wasn't that back in the old days when they also basically had no
multi-threading? (Assuming they even have decent threading today, which I'm
not sure of.) I found docs online claiming that FreeBSD for example had this
problem fixed back in 2004.

I also found documents about ecos not having a thread-safe getaddrinfo().

So it looks our configure script should check getaddrinfo() for
thread-safeness no matter what. How annoying.

-- 
  / daniel.haxx.se
-------------------------------------------------------------------
List admin: http://cool.haxx.se/list/listinfo/curl-library
Etiquette:  http://curl.haxx.se/mail/etiquette.html
Received on 2009-11-08

These mail archives are generated by hypermail.

donate! Page updated November 16, 2009.
web site info

File upload with ASP.NET