Subject: | connect bug |
Date: | Fri, 6 Nov 2009 00:04:17 +0000 |
To: | bug-Net-IRR [...] rt.cpan.org |
From: | Greg Skinner <gds [...] gds.best.vwh.net> |
perl, v5.8.8 built for i386-openbsd
OpenBSD ixrs-vm2.lab.equinix.com 4.3 GENERIC#0 i386
Net-IRR-0.06 distribution (patched to Net-IRR-0.07 by me three months
ago)
When attempting to connect to a whois server, and some failure
condition arises that would set the "errno" variable, undef is not
returned. Instead, you get an error message.
In this case, a connection attempt is made to a host that times out:
$ perl -w
use Net::IRR;
my $host = '192.168.219.10';
my $i = Net::IRR->connect( host => $host );
if (not defined($i)) {
print "failed: $!\n";
}
Can't call method "send" on an undefined value at /usr/local/libdata/perl5/site_perl/Net/IRR.pm line 126.
$ telnet 192.168.219.10 43
Trying 192.168.219.10...
telnet: connect to address 192.168.219.10: Connection timed out
In this case, a connection attempt is made to a host with nothing
listening on port 43:
$ perl -w
use Net::IRR;
my $host = 'localhost';
my $i = Net::IRR->connect( host => $host );
if (not defined($i)) {
print "failed: $!\n";
}
Can't call method "send" on an undefined value at /usr/local/libdata/perl5/site_perl/Net/IRR.pm line 126.
$ telnet localhost 43
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying 127.0.0.1...
telnet: connect to address 127.0.0.1: Connection refused
This patch (applied from a previous patch I sent in three months ago)
fixes the problem:
*** IRR-0.07.pm Thu Jul 30 10:11:28 2009
--- IRR-0.08.pm Wed Nov 4 15:55:58 2009
***************
*** 9,15 ****
use vars qw/ @ISA %EXPORT_TAGS @EXPORT_OK $VERSION /;
! $VERSION = '0.07';
# used for route searches
use constant EXACT_MATCH => 'o';
--- 9,15 ----
use vars qw/ @ISA %EXPORT_TAGS @EXPORT_OK $VERSION /;
! $VERSION = '0.08';
# used for route searches
use constant EXACT_MATCH => 'o';
***************
*** 33,39 ****
$self->{port} = $args{port} || 43;
eval {
local $SIG{__WARN__} = sub { $self->{errstr} = shift };
! $self->{tcp} = Net::TCP->new($self->{host}, $self->{port});
};
return undef if $self->error();
$self->_multi_mode();
--- 33,39 ----
$self->{port} = $args{port} || 43;
eval {
local $SIG{__WARN__} = sub { $self->{errstr} = shift };
! $self->{tcp} = Net::TCP->new($self->{host}, $self->{port}) or warn "cannot create Net::TCP object: $!\n";
};
return undef if $self->error();
$self->_multi_mode();