From owner-freebsd-hackers Mon Aug 9 17:56:18 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 C6DF414D75 for ; Mon, 9 Aug 1999 17:56:16 -0700 (PDT) (envelope-from ognir@humboldt1.com) Received: from shovel.groff (ppp177-pm5.humboldt1.com [207.104.21.170]) by home.humboldt1.com (Pro-8.9.2/Pro-8.9.2) with SMTP id RAA28787; Mon, 9 Aug 1999 17:53:48 -0700 (PDT) Date: Mon, 9 Aug 1999 17:53:48 -0700 (PDT) Message-Id: <199908100053.RAA28787@home.humboldt1.com> From: Joe Groff To: louie@TransSys.COM Cc: steve_tarkalson@hotmail.com, bmcgover@cisco.com, dan@trinsec.com, hackers@FreeBSD.ORG Reply-To: ognir@humboldt1.com Subject: Re: gethostbyaddr() and threads. In-Reply-To: <199908092322.TAA68246@whizzo.transsys.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 ---Louis A. Mamakos said: >> ---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. > Well, I guess we might as well change the API, since everyone else does. Unless someone comes up with a bettter idea, of course :) -Joe To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message