mostly-reentrant resolver/getaddrinfo(3)
Brian F. Feldman
green at FreeBSD.org
Mon Feb 9 08:36:41 PST 2004
"Jacques A. Vidrine" <nectar at 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 at FreeBSD.org \ The Power to Serve! \
Opinions expressed are my own. \,,,,,,,,,,,,,,,,,,,,,,\
More information about the freebsd-hackers
mailing list