Thread-safe gethostby* functions in AIX 4.3.3.

Thread-safe gethostby* functions in AIX 4.3.3.

Post by Nicholas Drone » Fri, 17 Aug 2001 06:47:30



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)

 
 
 

Thread-safe gethostby* functions in AIX 4.3.3.

Post by Gary R. Hoo » Fri, 17 Aug 2001 22:43:40



> 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.

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

*sigh*   Open a documentation APAR.

Quote:

>         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().

Quote:> 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).

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

Excellent question.

Quote:> 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
________________________________________________________________________

 
 
 

Thread-safe gethostby* functions in AIX 4.3.3.

Post by Nicholas Drone » Sat, 18 Aug 2001 02:22:47


Thanks Gary!  

I appreciate your conscientous response and good news.

What would we do without you? :-)

Regards,

Nicholas



>> 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.

 
 
 

1. Documentation for thread-safe network lookup functions.

Does anyone have a documentation link for the thread-safe network
configuration lookup functions? The ones I'm referring to include (from
AIX4.3.3's /usr/include/netdb.h):

extern int getnetbyaddr_r(in_addr_t net, int type, struct netent *netptr,
        struct netent_data *net_data);
extern int getnetbyname_r(const char *name, struct netent *netptr,
        struct netent_data *net_data);
extern int setnetent_r(int f, struct netent_data *net_data);
extern void endnetent_r(struct netent_data *net_data);
extern int getnetent_r(struct netent *net, struct netent_data *net_data);
extern int gethostbyname_r(const char *name, struct hostent *htent,
        struct hostent_data *ht_data);
extern int gethostbyaddr_r(char *addr, size_t len, int type,
        struct hostent *htent, struct hostent_data *ht_data);
extern int gethostent_r(struct hostent *htent, struct hostent_data
*ht_data);
extern void endhostent_r(struct hostent_data *ht_data);
extern void sethostent_r(int flag, struct hostent_data *ht_data);
extern int setservent_r(int f, struct servent_data *serv_data);
extern void endservent_r(struct servent_data *serv_data);
extern int getservent_r(struct servent *serv, struct servent_data
*serv_data);
extern int getservbyname_r(const char *name, const char *proto,
        struct servent *servptr, struct servent_data *serv_data);
extern int getservbyport_r(int port, const char *proto, struct servent
*servptr,        struct servent_data *serv_data);
extern int setprotoent_r(int f, struct protoent_data *proto_data);
extern void endprotoent_r(struct protoent_data *proto_data);
extern int getprotoent_r(struct protoent *proto,
        struct protoent_data *prot_data);
extern int getprotobyname_r(const char *name, struct protoent *protoptr,
        struct protoent_data *proto_data);
extern int getprotobynumber_r(int proto, struct protoent *protoptr,
         struct protoent_data *proto_data);
extern int setrpcent_r(int f, struct rpcent_data *rpc_data);
extern void endrpcent_r(struct rpcent_data *rpc_data);
extern int getrpcent_r(struct rpcent *rpcent, struct rpcent_data *rpc_data);
extern int getrpcbyname_r(const char *name, struct rpcent *rpcent,
                          struct rpcent_data *rpc_data);
extern int getrpcbynumber_r(int number, struct rpcent *rpcent,
                            struct rpcent_data *rpc_data);
extern int setnetgrent_r(char *, void **);
extern void endnetgrent_r(void **ptr);
extern int getnetgrent_r( char **, char **, char **, void **);
extern int innetgr_r(char *, char *, char *, char *, struct innetgr_data *);

--
John Muir
SDM Platform Software Design
NORTEL Networks

2. Port Mapping

3. Thread-safe functions

4. How to enter non-ASCII characters

5. Are the dl* functions thread-safe?

6. dns broken

7. Using thread-safe C library functions.

8. kpm load numbers scale?

9. Solaris 8 threads: If a routine is Async-Signal-Safe is it also thread Safe?

10. mmap, thread-safe, and signal-safe

11. Thread-safe and Signal-safe

12. Is inet_ntoa thread-safe on AIX 4.3?

13. OpenSSL+AIX+thread-safe[+64-bit]