develooper Front page | perl.perl5.porters | Postings from January 2001

Re: gethostbyname (was Re: Does perl really need to usesigsetjmp? (18% performance hit))

Thread Previous | Thread Next
From:
Dan Sugalski
Date:
January 26, 2001 09:43
Subject:
Re: gethostbyname (was Re: Does perl really need to usesigsetjmp? (18% performance hit))
Message ID:
5.0.2.1.0.20010126124135.01d39af0@24.8.96.48
At 04:58 PM 1/26/2001 +0000, Nicholas Clark wrote:
>On Sun, Jan 21, 2001 at 05:02:21PM +0000, Alan Burlison wrote:
> > Kinda both.  Perl5 threads are irredeemably broken, and IMHO should be
> > excised from the source as soon as possible - leaving them in only gives
> > the mistaken impression that they might actually work some day.  The
> > MT-unsafe behaviour of the current eval mechanism when used with threads
> > is just one of the reasons why they are so broken.
>
>And another. We're using gethostbyname. To quote an online Sun manpage:
>
>The functions gethostbyname() , gethostbyaddr() , and gethostent() use
>static storage that is reused in each call, making these functions unsafe
>for use in multi-threaded applications.
>
>The functions gethostbyname_r() , gethostbyaddr_r() , and gethostent_r()
>provide reentrant interfaces for these operations.
>
>[however, I don't know whether that many platforms provide the latter's
>functionality, and if so if they even use the same names]

It depends on your platform--some have threadsafe gethost* calls and don't 
need the _r version, and some don't. (And some aren't threadsafe but don't 
have _r versions...)

It's pretty much a crapshoot, unfortunately.

>How many other non thread-safe interfaces is perl5 using?

Oh, lots probably. Even more when you factor in other people's XS code, 
though that's not strictly fair.

>[actually, is that important - how much of C's undefined behaviour is
>perl5 source actually relying on]

Don't even ask that question--I'd bet we don't really want the answer... :)

					Dan

--------------------------------------"it's like this"-------------------
Dan Sugalski                          even samurai
dan@sidhe.org                         have teddy bears and even
                                      teddy bears get drunk


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About