Skip Menu |
 

This queue is for tickets about the IO CPAN distribution.

Report information
The Basics
Id: 90225
Status: resolved
Priority: 0/
Queue: IO

People
Owner: Nobody in particular
Requestors: fraserbn [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Handle getprotobyn{ame,umber} not being available
Download (untitled) / with headers
text/plain 1.1k
If perl is built with -Ud_getprotobyname -Ud_getprotobynumber, or if, like in Android, the OS lacks those functions, using them will cause a runtime exception saying that they aren't implemented. The patch below protects the calls with an eval {}, which works around the issue. Alternatively, this could be implemented as if ($Config{d_getprotobyname}) { getprotobyname() } (patch is against blead) diff --git a/dist/IO/lib/IO/Socket/INET.pm b/dist/IO/lib/IO/Socket/INET.pm index 4fa6a29..07f2b3f 100644 --- a/dist/IO/lib/IO/Socket/INET.pm +++ b/dist/IO/lib/IO/Socket/INET.pm @@ -50,7 +50,7 @@ sub _get_proto_number { return undef unless defined $name; return $proto_number{$name} if exists $proto_number{$name}; - my @proto = getprotobyname($name); + my @proto = eval { getprotobyname($name) }; return undef unless @proto; _cache_proto(@proto); @@ -62,7 +62,7 @@ sub _get_proto_name { return undef unless defined $num; return $proto_name{$num} if exists $proto_name{$num}; - my @proto = getprotobynumber($num); + my @proto = eval { getprotobynumber($num) }; return undef unless @proto; _cache_proto(@proto);
From: fraserbn [...] gmail.com
Download (untitled) / with headers
text/plain 1.3k
On Sun Nov 10 21:27:28 2013, Hugmeir wrote: Show quoted text
> If perl is built with -Ud_getprotobyname -Ud_getprotobynumber, or if, > like in Android, the OS lacks those functions, using them will cause a > runtime exception saying that they aren't implemented. > The patch below protects the calls with an eval {}, which works around > the issue. Alternatively, this could be implemented as if > ($Config{d_getprotobyname}) { getprotobyname() } > > (patch is against blead) > > diff --git a/dist/IO/lib/IO/Socket/INET.pm > b/dist/IO/lib/IO/Socket/INET.pm > index 4fa6a29..07f2b3f 100644 > --- a/dist/IO/lib/IO/Socket/INET.pm > +++ b/dist/IO/lib/IO/Socket/INET.pm > @@ -50,7 +50,7 @@ sub _get_proto_number { > return undef unless defined $name; > return $proto_number{$name} if exists $proto_number{$name}; > > - my @proto = getprotobyname($name); > + my @proto = eval { getprotobyname($name) }; > return undef unless @proto; > _cache_proto(@proto); > > @@ -62,7 +62,7 @@ sub _get_proto_name { > return undef unless defined $num; > return $proto_name{$num} if exists $proto_name{$num}; > > - my @proto = getprotobynumber($num); > + my @proto = eval { getprotobynumber($num) }; > return undef unless @proto; > _cache_proto(@proto); >
Er, minor correction, in the alternative using Config, it should be checking for d_getpbyname, not d_getprotobyname.
Ticket migrated to github as https://github.com/toddr/IO/issues/26


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.