Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 09 Aug 1999 12:54:39 -0600
From:      Wes Peters <wes@softweyr.com>
To:        Dan Moschuk <dan@trinsec.com>
Cc:        Tony Finch <dot@dotat.at>, hackers@FreeBSD.ORG
Subject:   Re: gethostbyaddr() and threads.
Message-ID:  <37AF23EF.8ADF5B2F@softweyr.com>
References:  <19990808204333.A40377@trinsec.com> <E11Dok0-000LN9-00@fanf.noc.demon.net> <19990809100626.A43835@trinsec.com>

next in thread | previous in thread | raw e-mail | index | archive | help
Dan Moschuk wrote:
> 
> | >After quite an exhausting night (of all the ways I didn't want to spend my
> | >Sunday...) I've managed to track down a problem that has been frustrating me
> | >all night.  The problem exists with multiple threads calling gethostbyaddr()
> | >(not necessarily at the same time).
> |
> | src/lib/libc/net/gethostbydns.c seems to use a load of static
> | variables in a non-thread-safe fashion.
> 
> Yes, I noticed that as well.  I also noticed that gethostbyaddr_r worked
> "less" than gethostbyaddr did (the result was that all threads ended up
> thrashing each other, and not of them continued on).  I was going to use
> res_query, but noticed that it too used static buffers (although it looks
> pretty easy to fix).
> 
> Would anyone be offended if I were to produce a few patches to fix up these
> routines once and for all?  Should I just produce a few #ifdef _THREAD_SAFEs
> or try full blown routines (gethostbyaddr_r, res_query_r)?

This is the second request for gethostbyaddr_r I've seen this week.  I've
been (oh so slowly) implementing the missing _r routines in our library and
documenting the hidden ones I've already found.  This is one of the uglier
ones.

Hacking up the mess we've got would be a waste of time, IMHO.  If you're going
to do it, go all the way and make a CLEAN implementation of the _r routines
and then implement the non _r routines on top of them.  If you need prototypes,
email back and I'll find the ones you want to work on first.  When you're
done, send me files or diffs and I'll be very happy to test them for you.  I'll
even help with the man pages.

-- 
            "Where am I, and what am I doing in this handbasket?"

Wes Peters                                                         Softweyr LLC
http://softweyr.com/                                           wes@softweyr.com


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?37AF23EF.8ADF5B2F>