Subject: Re: BIND 8.3.5
To: Bill Studenmund <wrstuden@netbsd.org>
From: Ian Lance Taylor <ian@airs.com>
List: tech-net
Date: 06/06/2003 14:14:53
Bill Studenmund <wrstuden@netbsd.org> writes:

> Ok, what data are we talking about? I'm gathering that net_data keeps data
> for gethostent() and gethostent_r(). Why?
> 
> I've always seen gethostent() as being documented as being _NOT_ thread
> safe. Why go to the trouble of making thread-safe calls that no one
> expects to be thread safe? Anyone who uses them will have taken thread
> safety protections already. ??
> 
> Also, I thought that gethostent_r() just used passed-in storage. Why make
> it thread safe, when it's explicitly encapsulated?

gethostent() essentially reads the next line from /etc/hosts (newer
versions read other stuff too, but the following point is still true).
gethostent_r() includes buffer space, but it implicitly knows the
location in /etc/hosts to read next.  In other words, gethostent_r()
does not encapsulate everything relevant to its execution.  There is
no easy way to do so, without adding some new openhostent() function
which has not been historically required.

> I greatly appreciate everyone's efforts to make NetBSD as thread-safe as
> possible, but shouldn't we be consistent with what other OSs are doing?
> I'd consider Solaris a good model to follow since they've been doing
> threads for so long. :-)

It's perhaps worth mentioning that I believe that gethostbyname()
(without the _r) is thread safe on AIX, HP/UX, and OSF.  But not, as
far as I know, Solaris.  I think gethostbyname_r() is thread safe on
all systems on which it is present, which in a typical implementation
implies that they use a _res structure stored in per-thread data.

Ian