misc/18824: gethostbyname is not thread safe

Craig Rodrigues rodrigc at crodrigues.org
Mon Feb 16 09:33:27 PST 2004


> The gethostbyname() is not thread safe. It causes lock ups if
>compiled with threads. It would be helpful if this is mentioned in
>the docs or if a thread-safe version is provided (gethostbyname_r
>?)

The gethostbyname() man page mentions in the BUGS section:

"These functions use static data storage; if the data is needed for future
 use, it should be copied before any subsequent calls overwrite it."


You should use the getaddrinfo() function which is reentrant, since
it doesn't use static data storage.

I think this PR should be closed.

-- 
Craig Rodrigues        
rodrigc at crodrigues.org


More information about the freebsd-threads mailing list