Is gethostbyname_r() reentrant?

Roland McGrath roland@redhat.com
Tue May 13 01:16:00 GMT 2003


> Checking the code, it seemed that the only difference between
> gethostbyname_r() function and gethostbyname() was where the result
> was placed.  Each thread would use the same socket when communicating
> with the DNS server, and it would be hard do know wich thread would
> recieve the DNS replies.

All the state such as the file descriptors for sockets live in the _res
data structure.  That is per-thread via macro magic or TLS, not a global
variable as it might appear to be (and was originally in the days before
threading support).



More information about the Libc-alpha mailing list