From: Ethan B. <ebl...@cs...> - 2006-08-21 11:44:33
|
Mark Doliner spake unto us the following wisdom: > On Mon, 21 Aug 2006 00:35:11 -0500, Gary Kramlich wrote > > Mark Doliner wrote: > > > We use either getaddrinfo() or gethostbyname(), and they are both blo= cking. > > > > I haven't looked at the changes, but I hope, now that it's threaded that > > we're using gethostbyname_r or gethostbyname2_r, since the man page say= s: > >=20 > > The functions gethostbyname() and gethostbyaddr() may return > > pointers to static data, which may be overwritten by later > > calls. Copying the struct hostent does not suffice, since it > > con=1B$B!>=1B(B tains pointers; a deep copy is required. > >=20 > > This of course, is implementation specific. >=20 > I'm working on that right now, actually. Unfortunately > gethostbyname_r() is a GNU extension, which means we shouldn't use it. > Which means that we'll have to use gethostbyname() in a blocking > manner on systems without addrinfo. Fortunately this should be a > relatively small number of systems. This is what I mentioned on IRC the other day, with respect to using reentrant lookups where available in case some other library chooses to do a lookup. (Viz. the recent gnome-vfs deciding to go threaded, for example.) gethostbyname_r is most certainly *not* GNU-specific, it exists on several systems that I am aware of. Perhaps the GNU implementation diverges in some way with, e.g., the Solaris version, but I expect we can assume they are the same. I'll peruse the man pages later and find out. Regression to blocking lookups on platforms without gethostbyname_r is a very good argument for returning to cooperating processes, if you ask me. :-P Ethan --=20 The laws that forbid the carrying of arms are laws [that have no remedy for evils]. They disarm only those who are neither inclined nor determined to commit crimes. -- Cesare Beccaria, "On Crimes and Punishments", 1764 |