Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 16 Feb 2004 12:33:41 -0500
From:      Craig Rodrigues <rodrigc@crodrigues.org>
To:        freebsd-gnats-submit@freebsd.org
Cc:        freebsd-threads@freebsd.org
Subject:   Re: misc/18824: gethostbyname is not thread safe
Message-ID:  <20040216173341.GA60096@crodrigues.org>

next in thread | raw e-mail | index | archive | help
> 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@crodrigues.org



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040216173341.GA60096>