Re: gethostbyname under 10.2
Re: gethostbyname under 10.2
- Subject: Re: gethostbyname under 10.2
- From: Jason Linhart <email@hidden>
- Date: Tue, 27 Aug 2002 16:36:41 -0400
On 8/27/02 12:22 AM Allan Nathanson (email@hidden) wrote:
>
On Tuesday, August 27, 2002, at 12:15 AM, Ryan McGann wrote:
>
>
> Is gethostbyname (or the reverse gethostbyaddress) thread-safe under
>
> Jaguar? Or must we wait for gethostbyname_r et. al?
>
>
Both gethostbyname and gethostbyaddr are thread-safe.
Are you sure about that?
Both of those routines return a (struct hostent *), which normally points
to static storage. On every other system, and according to the
implications of the man page, there is only one copy of that structure
that is shared by all calls to both routines from all threads.
On all other Unix like systems there are variant routines,
gethostbyname_r and gethostbyaddr_r, which take a pointer to a struct
hostent as an argument (instead of just returning one), that are thread
safe. Neither of these routines are defined in the headers shipped with
10.2.
The man page in 10.2 makes no claims of thread safety, instead it fairly
clearly implies that they are not at all thread safe. It does not make
alot of sense for Apple to have invented their own, incompatible, way of
making these routines thread safe only to fail to document it.
The corresponding OT routines are thread safe, but they are still
serialized across all threads in 10.2. If the BSD routines were thread
safe, I would have expected the OT glue routines to have been fixed to
take advantage of that.
Jason
-----------------
email@hidden
-----------------
Dr. Seuss books . . . can be read and enjoyed on several levels. For
example, 'One Fish Two Fish, Red Fish Blue Fish' can be deconstructed
as a searing indictment of the narrow-minded binary counting system.
-- Peter van der Linden, Expert C Programming, Deep C Secrets
_______________________________________________
macnetworkprog mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/macnetworkprog
Do not post admin requests to the list. They will be ignored.