Subject: Re: gethostbyname & gethostbyaddr in libc thread-safe yet?
To: None <tech-net@netbsd.org>
From: Christos Zoulas <christos@zoulas.com>
List: tech-net
Date: 05/25/2004 14:02:19
In article <200405251128.i4PBShU25901@eevee.engine.ca>,
Alicia da Conceicao <alicia@engine.ca> wrote:
>Sorry if this is a FAQ, but I was wondering if DNS routines
>"gethostbyname" & "gethostbyaddr" in libc have been made thread-
>safe yet?

No, and are are not planning to do this. Returning a static hostent
is not the only problem. The problem is also with error reporting;
checking h_errno after the call is an issue too. ISC solves these
problems by allocating a per-thread res_state; we've chosen to use
a pool, so res_state is not available after the return of gethostby*().
I'd suggest you convert your code to use getaddrinfo() which is
re-entrant. In the future we might provide _r versions of
getfoobybar*(), but since there are no real standards for those,
I would not hold by breath. I will let Brian Ginbach and others correct
this, if I am wrong.

christos