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