Subject: Re: gethostbyname & gethostbyaddr in libc thread-safe yet?
To: Alicia da Conceicao <alicia@engine.ca>
From: Christos Zoulas <christos@zoulas.com>
List: tech-net
Date: 05/26/2004 08:07:45
On May 26,  1:15am, alicia@engine.ca (Alicia da Conceicao) wrote:
-- Subject: Re: gethostbyname & gethostbyaddr in libc thread-safe yet?

| > > The manual page of getaddrinfo is out of date (it is thread-safe in
| > > NetBSD-current). I would suggest to look into linking with the lwres_
| > > library that comes with bind9. Other than that, you can use mutexes
| > > to protect the current gethostbyfoo(), but that will make it really
| > > slow. Another approach is to fork, which is worse.
| > 	no, getaddrinfo is not thread-safe yet in netbsd-current.
| > 	getadddrinfo: _yp_getaddrinfo, see variable __ypcurrent
| 
| Dammit, I just finished modifing my code to replace all of the "gethostbyname"
| & "gethostbyaddr" routines with "getaddrinfo" & "getnameinfo", since I thought
| these are thread-safe in NetBSD-current.  (BTW I am running NetBSD 2.0E.)
| Since "getaddrinfo" & "getnameinfo" are not thread-safe, I will have to code
| in yet another alternative.
| 
| On a old Linux 2.4.* machine, its "getaddrinfo" & "getnameinfo" routines have
| been thread safe for quite a while, so why not rip out the code for libc in
| NetBSD-current?  In 2004, it is not unreasonable to expect some thread safe
| routines in NetBSD's libc, when Microsoft and even Linux and Solaris have had
| them for many years.
| 
| ==========================================================================
| getaddrinfo(3)      Linux Programmer's Manual      getaddrinfo(3)
| ...
|        The  thread-safe getaddrinfo(3) function creates one or more socket
| ...
| ==========================================================================
| 
| When I have time, I will likely end up coding my own cross-platform, thread-
| safe DNS resolver client library from scratch, or if I am lazy, I will just
| rip out the tiny DNS resolver client from uClibc.

I you using YP? If you are not, you should be ok. If you are, drop me a note
and I will fix it.

christos