From owner-freebsd-hackers Mon Aug 9 15:58: 1 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from home.humboldt1.com (home.humboldt1.com [206.13.45.1]) by hub.freebsd.org (Postfix) with ESMTP id 508BD153F0 for ; Mon, 9 Aug 1999 15:57:54 -0700 (PDT) (envelope-from ognir@humboldt1.com) Received: from shovel.groff (ppp227-pm6.humboldt1.com [207.104.21.220]) by home.humboldt1.com (Pro-8.9.2/Pro-8.9.2) with SMTP id PAA08129; Mon, 9 Aug 1999 15:55:37 -0700 (PDT) Date: Mon, 9 Aug 1999 15:55:37 -0700 (PDT) Message-Id: <199908092255.PAA08129@home.humboldt1.com> From: Joe Groff To: steve_tarkalson@hotmail.com Cc: bmcgover@cisco.com, dan@trinsec.com, hackers@FreeBSD.ORG Reply-To: ognir@humboldt1.com Subject: Re: gethostbyaddr() and threads. In-Reply-To: <19990809224120.39659.qmail@hotmail.com> X-Mailer: XCmail 1.0.0 - with PGP support, PGP engine version 0.5 (FreeBSD) X-Mailerorigin: http://www.fsai.fh-trier.de/~schmitzj/Xclasses/XCmail/ MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 7bit 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. -Joe To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message