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)
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
________________________________________________________________________
I appreciate your conscientous response and good news.
What would we do without you? :-)
Regards,
Nicholas