This is the mail archive of the
libc-alpha@sources.redhat.com
mailing list for the glibc project.
Re: Is gethostbyname_r() reentrant?
- From: Roland McGrath <roland at redhat dot com>
- To: Petter Reinholdtsen <pere at hungry dot com>
- Cc: libc-alpha at sources dot redhat dot com
- Date: Mon, 12 May 2003 18:16:38 -0700
- Subject: Re: Is gethostbyname_r() reentrant?
> 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).