Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 31 May 2002 16:35:13 -0500
From:      Dan Nelson <dnelson@allantgroup.com>
To:        Peter Haight <peterh@sapros.com>
Cc:        Clint Olsen <clint@0lsen.net>, hackers@FreeBSD.ORG
Subject:   Re: Is gethostbyname2() reentrant?
Message-ID:  <20020531213513.GC58285@dan.emsphone.com>
In-Reply-To: <200205312101.g4VL1vvj057289@wartch.sapros.com>
References:  <200205312101.g4VL1vvj057289@wartch.sapros.com>

next in thread | previous in thread | raw e-mail | index | archive | help
In the last episode (May 31), Peter Haight said:
> >On May 31, Peter Haight wrote:
> >> 
> >> If I link with libc_r can I use gethostbyname2() at the same time
> >> in two different threads?
> >
> >Pardon my ignorance, but how does re-entrancy affect this?  It would
> >seem that you're interested in a function that doesn't block.
> 
> The function returns a pointer to some sort of memory. I'm worried
> that the the two separate requests could possibly mess up each others
> memory. Maybe I have the terminology wrong.

According to the manpage:

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

Actually, gethostbyname2 uses nsdispatch to do the dirty work, and its
manpage is even more explicit:

BUGS
     The nsdispatch routines are not thread safe.  This will be
     rectified in the future.

You'll have to serialize access to it yourself.

-- 
	Dan Nelson
	dnelson@allantgroup.com

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




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