Skip Menu |

This queue is for tickets about the Net-Whois-Proxy CPAN distribution.

Report information
The Basics
Id: 38080
Status: resolved
Worked: 10 min
Priority: 0/
Queue: Net-Whois-Proxy

People
Owner: CFABER [...] cpan.org
Requestors: gary.richardson [...] gmail.com
Cc:
AdminCc:

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



Subject: Long running processes an alarm()
I have a script that does thousands of whois lookups. I'm getting 'random' timeout errors. I've tracked the problem down to line ~625 of Proxy.pm: eval { $SIG{ALRM} = sub { die 'timeout'; }; alarm(($timeout || $self->{master_timeout}) + 5); $sock = IO::Socket::INET->new( Proto => 'tcp', PeerAddr => $serv || $self->{master_whois}, PeerPort => $port || $self->{master_port}, Timeout => $timeout || $self->{master_timeout} ) || die "Unable to create socket $!"; alarm(0); }; alarm(0) doesn't get called if the socket creation fails. If connections fail for $timeout seconds, $SIG{ALRM} is called outside of the eval block. I fixed it by changing it to: $SIG{ALRM} = sub { die 'timeout'; }; alarm(($timeout || $self->{master_timeout}) + 5); eval { $sock = IO::Socket::INET->new( Proto => 'tcp', PeerAddr => $serv || $self->{master_whois}, PeerPort => $port || $self->{master_port}, Timeout => $timeout || $self->{master_timeout} ) || die "Unable to create socket $!"; }; alarm(0); So that alarm(0) is always called.
Hi, Thanks for the suggestion. I've made some changes which should correct the two issues within this library. -cf