delorie.com/archives/browse.cgi   search  
Mail Archives: cygwin/2003/02/10/21:37:03

Mailing-List: contact cygwin-help AT cygwin DOT com; run by ezmlm
List-Subscribe: <mailto:cygwin-subscribe AT cygwin DOT com>
List-Archive: <http://sources.redhat.com/ml/cygwin/>
List-Post: <mailto:cygwin AT cygwin DOT com>
List-Help: <mailto:cygwin-help AT cygwin DOT com>, <http://sources.redhat.com/ml/#faqs>
Sender: cygwin-owner AT cygwin DOT com
Mail-Followup-To: cygwin AT cygwin DOT com
Delivered-To: mailing list cygwin AT cygwin DOT com
X-Authentication-Warning: slinky.cs.nyu.edu: pechtcha owned process doing -bs
Date: Mon, 10 Feb 2003 21:36:53 -0500 (EST)
From: Igor Pechtchanski <pechtcha AT cs DOT nyu DOT edu>
Reply-To: cygwin AT cygwin DOT com
To: Ajay Nerurkar <ajaynerurkar AT yahoo DOT com>
cc: cygwin AT cygwin DOT com
Subject: Re: gethostbyname thread-safe?
In-Reply-To: <20030211012218.5594.qmail@web12501.mail.yahoo.com>
Message-ID: <Pine.GSO.4.44.0302102103300.3160-100000@slinky.cs.nyu.edu>
Importance: Normal
MIME-Version: 1.0

On Mon, 10 Feb 2003, Ajay Nerurkar wrote:

> Is Cygwin's gethostbyname thread-safe? From a web search I got the
> impression that it wasn't and also that Cygwin does not have its
> reentrant version gethostbyname_r. So, what does one do?
>
> Ajay

Ajay,

Looking at the code (src/winsup/cygwin/net.cc),

964:#ifdef _MT_SAFE
965:#define hostent_buf  _reent_winsup ()->_hostent_buf
966:#else
967:static struct hostent *hostent_buf = NULL;
968:#endif
969:
970:/* exported as gethostbyname: standards? */
971:extern "C" struct hostent *
972:cygwin_gethostbyname (const char *name)

you can see that there is a provision for reentrancy.  However,
src/winsup/cygwin/acconfig.h #undef's _MT_SAFE.  OpenGroup's specification
(<http://www.opengroup.org/onlinepubs/007904975/functions/gethostbyaddr.html>)
says that "The gethostbyname() function need not be reentrant."
See <http://wcug.wwu.edu/lists/ipng/199710/msg00002.html> for a good
discussion of gethostbyname() thread-safety issues.

So, your choices for the moment are:
1) build a thread-safe cygwin1.dll for your own use
2) make sure gethostbyname() is only called (and its result used/copied)
   by one thread at a time (using a mutex, for example)
3) implement gethostby{name,addr}_r() yourself and submit a patch

Hope this helps,
	Igor
-- 
				http://cs.nyu.edu/~pechtcha/
      |\      _,,,---,,_		pechtcha AT cs DOT nyu DOT edu
ZZZzz /,`.-'`'    -.  ;-;;,_		igor AT watson DOT ibm DOT com
     |,4-  ) )-,_. ,\ (  `'-'		Igor Pechtchanski
    '---''(_/--'  `-'\_) fL	a.k.a JaguaR-R-R-r-r-r-.-.-.  Meow!

Oh, boy, virtual memory! Now I'm gonna make myself a really *big* RAMdisk!
  -- /usr/games/fortune


--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Bug reporting:         http://cygwin.com/bugs.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019