misc/18824: gethostbyname is not thread safe

Craig Rodrigues rodrigc at crodrigues.org
Mon Feb 16 09:40:13 PST 2004


The following reply was made to PR misc/18824; it has been noted by GNATS.

From: Craig Rodrigues <rodrigc at crodrigues.org>
To: freebsd-gnats-submit at freebsd.org
Cc: hook at aktrad.ru, freebsd-threads at freebsd.org
Subject: Re: misc/18824: gethostbyname is not thread safe
Date: Mon, 16 Feb 2004 12:33:41 -0500

 > 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