Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 09 Aug 1999 19:22:01 -0400
From:      "Louis A. Mamakos" <louie@TransSys.COM>
To:        ognir@humboldt1.com
Cc:        steve_tarkalson@hotmail.com, bmcgover@cisco.com, dan@trinsec.com, hackers@FreeBSD.ORG
Subject:   Re: gethostbyaddr() and threads. 
Message-ID:  <199908092322.TAA68246@whizzo.transsys.com>
In-Reply-To: Your message of "Mon, 09 Aug 1999 15:55:37 PDT." <199908092255.PAA08129@home.humboldt1.com> 
References:  <199908092255.PAA08129@home.humboldt1.com> 

next in thread | previous in thread | raw e-mail | index | archive | help
> ---Steve Tarkalson said:
> > this is solved by one of two methods:
> >    1-) require the caller of gethostbyaddr() to supply a pointer to
> >        a hostent struct which will be filled.
> > or 2-) the library uses thread specific storage which is re-used in
> >        each call.
> > 
> You could malloc() a struct hostent for each call to
> gethostby*(), each time registering the hostent in some list along with the
> thread's PID. If the same thread calls gethostby*, use the same buffer, or
> allocate a new one if another thread calls it. Have a static function be called
> atexit to free all the mallocs.

Yuk!

If you're writing a multithreaded program, a slightly different API for
gethostbyname() is likely to be the least of your worries.





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?199908092322.TAA68246>