Subject: | RE: [http://rt.cpan.org #124830] Net::Ping croaks when a name cannot be resolved |
Date: | Tue, 20 Mar 2018 12:12:22 +0000 |
To: | "bug-Net-Ping [...] rt.cpan.org" <bug-Net-Ping [...] rt.cpan.org> |
From: | "Dave Stafford [Globis]" <dstafford [...] mhg.co.za> |
Hi Reini, thanks for the quick reply.
Show quoted text
>Is carp acceptable? (warn with backtrace) or should it silently fail.
Well I guess either would work as it would preserve backwards compatibility, although ideally it would be nice to be to have a mechanism to pick up any messages.
For example a common pattern I use with DBI is :
my $sql=”select ..”;
my $retval=$dbh->selectall_hashref($sql ..);
if ( $DBI::errstr ) { handle_error..}
So for Net::Ping it could be:
my $rc=$p->ping($host, 2);
if ( $Net::Ping::errstr ) { handle_error..}
Of course this is how I work and I’m sure there are many equally good ways to manage this.
Dave
From: Reini Urban via RT [mailto:bug-Net-Ping@rt.cpan.org]
Sent: 20 March 2018 13:57
To: Dave Stafford [Globis]
Subject: [http://rt.cpan.org #124830] Net::Ping croaks when a name cannot be resolved
<URL: https://rt.cpan.org/Ticket/Display.html?id=124830<https://rt.cpan.org/Ticket/Display.html?id=124830> >
On Tue Mar 20 05:41:08 2018, dstafford@mhg.co.za<mailto:dstafford@mhg.co.za> wrote:
Show quoted text> I've just upgraded from Perl 5.20 to 5.24 on a Windows server and a
> lot of scripts that use Net::Ping have been broken because it now
> croaks when host resolution fails.
>
> Previously with perl 5.20 Net::Ping was version 2.43, and when lookup
> failed it returned undef:
>
> 377: $ip = inet_aton($host);
> 378: return () unless defined($ip); # Does host exist?
>
> Now in version 2.66 if the name lookup fails in the new _resolv
> routine it croaks, breaking all existing scripts, and contradicting
> the documentation which states it will return undef if lookup fails :
>
> 1878: croak(sprintf("getaddrinfo($h{host},,%s) failed - $err",
> 1879: $family == AF_INET ? "AF_INET" : "AF_INET6"));
>
>
> Note that earlier in this routine there is the line:
>
> 1830 # numeric address, return
> 1831 my ($err, @getaddr) = Socket::getaddrinfo($h{host}, undef,
> \%hints);
>
> But even though this (in my case) returns an error message for host
> not found, it continues down to the later code that croaks
I see, that's annoying.
Is carp acceptable? (warn with backtrace) or should it silently fail.
**********************************************************************************************************************
---------
NOTICE
---------
This message (including attachments) contains privileged and confidential information intended only for the person or entity to which it is addressed.
Any review, retransmission, dissemination, copy or other use of, or taking of any action in reliance upon this information by persons or entities other than the intended recipient, is prohibited.
If you received this message in error, please notify the sender immediately by e-mail, facsimile or telephone and thereafter delete the material from any computer.
Metropolitan Health, its subsidiaries or associates, does not accept liability for any personal views expressed in this message.
Metropolitan Health
PO Box 4313 Cape Town 8000 Tel: 021 480 4511 Fax: 021 480 4535 www.mhg.co.za
**********************************************************************************************************************