From owner-freebsd-hackers@FreeBSD.ORG Mon Feb 9 08:36:41 2004 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from green.bikeshed.org (freefall.freebsd.org [216.136.204.21]) by hub.freebsd.org (Postfix) with ESMTP id 01DA016A4CE; Mon, 9 Feb 2004 08:36:41 -0800 (PST) Received: from green.homeunix.org (green@localhost [127.0.0.1]) by green.bikeshed.org (8.12.10/8.12.9) with ESMTP id i19Gad6w024700; Mon, 9 Feb 2004 11:36:40 -0500 (EST) (envelope-from green@green.homeunix.org) Received: from localhost (green@localhost)i19GaYYk024697; Mon, 9 Feb 2004 11:36:39 -0500 (EST) Message-Id: <200402091636.i19GaYYk024697@green.homeunix.org> X-Mailer: exmh version 2.6.3 04/04/2003 with nmh-1.0.4 To: "Jacques A. Vidrine" In-Reply-To: Message from "Jacques A. Vidrine" <20040209131604.GA71929@madman.celabo.org> From: "Brian F. Feldman" Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Mon, 09 Feb 2004 11:36:34 -0500 Sender: green@green.homeunix.org cc: hackers@FreeBSD.org Subject: Re: mostly-reentrant resolver/getaddrinfo(3) X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 09 Feb 2004 16:36:41 -0000 "Jacques A. Vidrine" wrote: > > BTW, a slightly more complete patch that has the diffs for > > /usr/include/resolv.h and also should correctly close the sockets that each > > thread opens for the resolver can be found here: > > > > http://green.homeunix.org/~green/mostly_reentrant_resolver.patch > > Cool! > > Use pthread_once for creating keys, not a mutex (referring to > res_init_mutex/res_keys_inited). > > I prefer to see `_pthread_*' in libc source (rather than `thr_*'), but > that's just me. If I try to use pthread_once(3) then I still need to have a variable which stores whether the call to pthread_key_create(3) succeeded from the pthread_once(3), right? So at the least, I'd have something like: static once_t keyonce; static int keyfailed; static void key_allocate(void) { if (thr_keycreate(foo, bar) != 0) keyfailed = 1; } static void allocate(void) { if (thr_once(&keyonce, key_allocate) != 0 || keyfailed) return (&_res_bogus); } It would be so much nicer if pthread_once(once, func, retval) existed, but I guess this would probably still work.... -- Brian Fundakowski Feldman \'[ FreeBSD ]''''''''''\ <> green@FreeBSD.org \ The Power to Serve! \ Opinions expressed are my own. \,,,,,,,,,,,,,,,,,,,,,,\