Date: Mon, 09 Feb 2004 11:36:34 -0500 From: "Brian F. Feldman" <green@FreeBSD.org> To: "Jacques A. Vidrine" <nectar@FreeBSD.org> Cc: hackers@FreeBSD.org Subject: Re: mostly-reentrant resolver/getaddrinfo(3) Message-ID: <200402091636.i19GaYYk024697@green.homeunix.org> In-Reply-To: Message from "Jacques A. Vidrine" <nectar@FreeBSD.org> <20040209131604.GA71929@madman.celabo.org>
next in thread | previous in thread | raw e-mail | index | archive | help
"Jacques A. Vidrine" <nectar@FreeBSD.org> 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. \,,,,,,,,,,,,,,,,,,,,,,\
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200402091636.i19GaYYk024697>