Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Thread-safe gethostby* functions in AIX 4.3.3.

10 views
Skip to first unread message

Nicholas Dronen

unread,
Aug 15, 2001, 5:47:30 PM8/15/01
to
The documentation for gethostbyaddr in AIX 4.3.3 makes
me want to inflict pain. It says:

Attention: Do not use the gethostbyaddr subroutine
in a multithreaded environment.

However, no documentation for gethostbyaddr_r exists, although
there's a prototype for it in netdb.h:

extern int gethostbyaddr_r(char *addr, size_t len, int type,
struct hostent *htent, struct hostent_data *ht_data);

I notice also that there's a prototype for gethostbyname_r, but the
documentation for gethostbyname says:

Note: The gethostbyname subroutine is threadsafe in AIX Version 4.3.

So, why is there a prototype for gethostbyname_r in netdb.h if
gethostbyname itself is threadsafe? Why does the gethostbyaddr
documentation not suggest to use gethostbyaddr_r instead of
gethostbyaddr in a threaded program? Is gethostbyname now just
a wrapper around gethostbyname_r? Is gethostbyaddr a wrapper
around gethostbyaddr_r as well, sans reasonable documentation?

Regards,

Nicholas Dronen

--
$ more worth doing
/dev/null (END)

Gary R. Hook

unread,
Aug 16, 2001, 9:43:40 AM8/16/01
to
Nicholas Dronen wrote:
>
> The documentation for gethostbyaddr in AIX 4.3.3 makes
> me want to inflict pain. It says:
>
> Attention: Do not use the gethostbyaddr subroutine
> in a multithreaded environment.

This appears to be a pre-4.3 era warning.

> However, no documentation for gethostbyaddr_r exists, although
> there's a prototype for it in netdb.h:

*sigh* Open a documentation APAR.

>
> extern int gethostbyaddr_r(char *addr, size_t len, int type,
> struct hostent *htent, struct hostent_data *ht_data);
>
> I notice also that there's a prototype for gethostbyname_r, but the
> documentation for gethostbyname says:
>
> Note: The gethostbyname subroutine is threadsafe in AIX Version 4.3.

This is correct, it appears, looking at the source. Same for
gethostbyaddr().

> So, why is there a prototype for gethostbyname_r in netdb.h if
> gethostbyname itself is threadsafe?

Lots of 4.1/4.2 holdovers. Recall that the threaded version
of libc used to be a completely separate library, and building
threaded apps prior to 4.3 required special steps (and a certain
amount of pain).

> Why does the gethostbyaddr
> documentation not suggest to use gethostbyaddr_r instead of
> gethostbyaddr in a threaded program?

Excellent question.

> Is gethostbyname now just
> a wrapper around gethostbyname_r?

The other way around, essentially. Everything in libc is thread-safe
now.

--
Gary R. Hook / AIX PartnerWorld for Developers / These opinions are MINE
________________________________________________________________________

Nicholas Dronen

unread,
Aug 16, 2001, 1:22:47 PM8/16/01
to
Thanks Gary!

I appreciate your conscientous response and good news.

What would we do without you? :-)

Regards,

Nicholas

0 new messages