From owner-freebsd-hackers Sun Sep 15 9:17:21 2002 Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.FreeBSD.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id AD56837B400 for ; Sun, 15 Sep 2002 09:17:18 -0700 (PDT) Received: from flamingo.mail.pas.earthlink.net (flamingo.mail.pas.earthlink.net [207.217.120.232]) by mx1.FreeBSD.org (Postfix) with ESMTP id 1DEC743E42 for ; Sun, 15 Sep 2002 09:17:18 -0700 (PDT) (envelope-from tlambert2@mindspring.com) Received: from pool0350.cvx40-bradley.dialup.earthlink.net ([216.244.43.95] helo=mindspring.com) by flamingo.mail.pas.earthlink.net with esmtp (Exim 3.33 #1) id 17qc4r-0000HU-00; Sun, 15 Sep 2002 09:16:54 -0700 Message-ID: <3D84B235.D6E671D6@mindspring.com> Date: Sun, 15 Sep 2002 09:15:49 -0700 From: Terry Lambert X-Mailer: Mozilla 4.79 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: Valentin Nechayev Cc: Jev , hackers@FreeBSD.ORG Subject: Re: gethostbyname_r() fbsd equiv? References: <20020913145830.GB41842@ecad.org> <3D820700.DB53B0F9@mindspring.com> <20020913160214.GB42538@ecad.org> <3D820DD0.985F9C66@mindspring.com> <20020915111422.GA1077@iv.nn.kiev.ua> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Valentin Nechayev wrote: > SUSv3 doesn't know any gethostbyname_r. One can select either HP-UX/AIX > or Solaris/Linux version of interface, but the more correct way is possibly > to inplement getaddrinfo() in thread-safe way. getaddrinfo() is known > even for Microsoft (latest versions). I think you missed earlier, where I pointed out that AIX and HP/UX now use thread local storage versions of the functions, so that their external interface is unchanged. For FreeBSD to do this, people would need to permit two changes; the first would be to erase some of the distinction between the C++ startup code (i.e. c++rt0.c) and the C version. Specifically, the .init section can be replaces, but is not itself treated as a linker set by the compiler. The C++ code that does the constructor initialization for stacically initialized constructors and pure virtual base classes *is* a linker set. What this basically means is that rather than overloading the .init (which is not allowed -- you may only override it), the ability to set up thread local storage code requires that you implement in the constructor linker set space. This, in turn, means that C programs that want to do this automatically, without needing a magic function or a "static int once = 1;" thing must be linked against the C++ code that understands the constructors. The other change that is necessary is that the void argument functions require passing of the address of argc (really, they should pass the address of the kframe structure, but since argc is the first value, passing it's address is the same thing as passing the address of the kframe struct itself). See:" /usr/src/lib/csu/i386/crt0.c for more enightenment. I have code that, if this is done, permits the implementation of the code we have been talking about. In an absolutely ideal world, there would be linker-setted "thread attach" and "thread detach" methods, which would be required to be called on pthread creation and destruction, so that it was possible to do resource tracking precreation and cleanup of thread local storage areas for any call that needed this type of thing. > For now I can't understand why thread-safe resolver from BIND >= 8.2 wasn't > imported. For applications where it is nesessary (e.g. milter filter with > extended checking of sender validity), we had to compile libbind and link > it in non-natural way.;( getaddrinfo/getnameinfo can be rewritten for > thread-safe resolver mechanically, without advanced thinking. > > P.S. BIND source has version of gethostbyaddr_r and only it should be > named as canonical. The BIND code wasn't imported for two reasons: 1) The resolver in FreeBSD is not in a separate library, it is in libc, so it is hard to track modifications to the resolver without introducing a proliferation of version numbers for the C library. This isn't easily correctable, since: a) The resolver is assumed to be part of the C library for most code b) There are programs which assume the resolver is there, which are themselves statically linked. While ELF supports linking one shared library against another, which would hid the dependency of a libc on a libresolv and allow transparent migration, the antique static linking does not support library dependencies in ELF, so all of these statically linked programs compilation would have to be changed 2) The resolver library in FreeBSD has been substantially modified by the KAME IPv6 code being imported into FreeBSD. This code substantially predates the "BIND >= 8.2" support for IPv6, which you are referencing. Probably the canonically correct thing to do would be to move the resolver out of libc. Doing this brings out such amazing opposition that it's like trying to build a new freeway, and having the residents whose houses will have to be torn down insist on being able to use their houses until you cut the ribbon on the freeway itself. If you want to pursue moving the resolver out of libc, I'll add my voice in support of the idea. However, I don't expect that you will be very successful in implementing this idea incrementally, the way everyone will demand that it be implemented, so that it doesn't impact them (after all, why do they need these extra features?). -- Terry To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message