From owner-freebsd-hackers Mon Aug 9 16:24:33 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from whizzo.transsys.com (whizzo.TransSys.COM [144.202.42.10]) by hub.freebsd.org (Postfix) with ESMTP id CA85C1536A for ; Mon, 9 Aug 1999 16:24:29 -0700 (PDT) (envelope-from louie@whizzo.transsys.com) Received: from whizzo.transsys.com (localhost.transsys.com [127.0.0.1]) by whizzo.transsys.com (8.9.3/8.9.1) with ESMTP id TAA68246; Mon, 9 Aug 1999 19:22:01 -0400 (EDT) (envelope-from louie@whizzo.transsys.com) Message-Id: <199908092322.TAA68246@whizzo.transsys.com> X-Mailer: exmh version 2.0.2 2/24/98 To: ognir@humboldt1.com Cc: steve_tarkalson@hotmail.com, bmcgover@cisco.com, dan@trinsec.com, hackers@FreeBSD.ORG From: "Louis A. Mamakos" Subject: Re: gethostbyaddr() and threads. References: <199908092255.PAA08129@home.humboldt1.com> In-reply-to: Your message of "Mon, 09 Aug 1999 15:55:37 PDT." <199908092255.PAA08129@home.humboldt1.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Mon, 09 Aug 1999 19:22:01 -0400 Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG > ---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