Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 11 Apr 2000 22:38:58 -0700
From:      Arun Sharma <adsharma@sharmas.dhs.org>
To:        ming@yahoo-inc.com
Cc:        hackers@freebsd.org
Subject:   Re: Multithread safe gethostbyname() ?
Message-ID:  <200004120538.WAA17491@sharmas.dhs.org>
In-Reply-To: <Pine.BSF.4.10.10004111813310.81762-100000@pious.yahoo.com>
References:  <Pine.BSF.4.10.10004111813310.81762-100000@pious.yahoo.com>

next in thread | previous in thread | raw e-mail | index | archive | help
In muc.lists.freebsd.hackers, you wrote:
> 
> Is there a MT-safe implementation of gethostbyname() in FreeBSD (3.4/4.0)?
> 
> On Solaris there is gethostbyname_r().  Calling gethostbyname() with in
> two threads cause both threads to block.

You seem to be talking about two different things:

1. A reentrant function - two different threads can be in the same function
   simultaneously

2. A non blocking function.

Reading the code in /usr/src/lib/libc{,_r}, it appears to me that, the
FreeBSD implementation is not reentrant, and blocking. However,
gethostbyname calls poll(2), which causes a reschedule to another runnable
pthread, if any.

In your case, both the threads are waiting for a DNS server response,
so the thread scheduler doesn't have a thread to schedule.

I think it'd be very useful to have a non-blocking DNS lookup API (one
which exposes the underlying file descriptor) . Winsock has this. UNIX
netscape 4.x would freeze half as often if this was done right.

	-Arun


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?200004120538.WAA17491>