From owner-freebsd-hackers Wed Apr 12 13: 4:19 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from sharmas.dhs.org (c62443-a.frmt1.sfba.home.com [24.0.69.165]) by hub.freebsd.org (Postfix) with ESMTP id B1FB437BA1D for ; Wed, 12 Apr 2000 13:04:06 -0700 (PDT) (envelope-from adsharma@sharmas.dhs.org) Received: (from adsharma@localhost) by sharmas.dhs.org (8.9.3/8.9.3) id NAA19717; Wed, 12 Apr 2000 13:03:47 -0700 Date: Wed, 12 Apr 2000 13:03:47 -0700 From: Arun Sharma To: Ming Zhang Cc: hackers@freebsd.org Subject: Re: Multithread safe gethostbyname() ? Message-ID: <20000412130347.A19577@sharmas.dhs.org> References: <200004120538.WAA17491@sharmas.dhs.org> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 0.95.6i In-Reply-To: ; from Ming Zhang on Wed, Apr 12, 2000 at 12:07:40AM -0700 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG On Wed, Apr 12, 2000 at 12:07:40AM -0700, Ming Zhang wrote: > > In your case, both the threads are waiting for a DNS server response, > > so the thread scheduler doesn't have a thread to schedule. > > If I only create one thread, then the gethostbyname() returns immediately. > By using truss -p, it seems that gethostbyname() uses a static socket var > for the DNS I/O rather than a local one, and that I think is what caused > the threads to hang. Or, we're talking about the same thing? Ah, I see. So your problem is due to the non-reentrant nature of the implementation rather than the blocking nature (as I assumed earlier). While we're on the topic, it'd also be useful to have a DNS lookup mechanism, that's per domain/adapter. If I have a laptop connected to two private domains foo.com and bar.com, I wan't nslookups on *.foo.com to go to one DNS server and *.bar.com to another. That'd require a per domain or per adapter /etc/resolv.conf -Arun To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message